Function
コメント・参照等
function (obj, col_data = 2, colour = "black", fill = "#87cefa", lab_title = NULL, source_name = NULL, density_fill_colour = "#008080", density_alpha = 0.2, show_legend = F)
{
if (is.null(lab_title)) {
lab_title <- paste0(colnames(obj)[col_data], ":n=", length(obj[, col_data]))
}
g <- ggplot(data = obj, mapping = aes_string(x = colnames(obj)[col_data]))
g <- g + geom_histogram(mapping = aes(y = ..density..), colour = colour, fill = fill, show.legend = show_legend)
g <- g + geom_density(fill = density_fill_colour, alpha = density_alpha, show.legend = show_legend)
g <- g + labs(title = lab_title)
if (!is.null(source_name)) {
g <- g + labs(subtitle = paste0("Source:", source_name))
}
return(g)
}