I want to overlay a few density plots in R and know that there are a few ways to do that, but they don\'t work for me for a reason or another (\'sm\' library doesn\'t instal
Some people have asked if you can do this when the distributions are of different lengths. The answer is yes, just use a list instead of a data frame.
library(ggplot2)
library(reshape2)
x <- list(v1=rnorm(100),v2=rnorm(50,1,1),v3=rnorm(75,0,2))
data<- melt(x)
ggplot(data,aes(x=value, fill=L1)) + geom_density(alpha=0.25)
ggplot(data,aes(x=value, fill=L1)) + geom_histogram(alpha=0.25)
ggplot(data,aes(x=L1, y=value, fill=L1)) + geom_boxplot()