powered by
This function generates density plots using ggplot2 grouped by a specified class label from a data frame containing numeric values.
plot_density_class( data, class_label, label_x = "", label_y = "", colors = NULL, bin = NULL, alpha = 0.5 )
returns a ggplot graphic
data.frame contain x, value, and variable
name of attribute for class label
x-axis label
y-axis label
color vector
bin width for density estimation
level of transparency
grf <- plot_density_class(iris |> dplyr::select(Sepal.Width, Species), class = "Species", colors=c("red", "green", "blue")) plot(grf)
Run the code above in your browser using DataLab