neversaint neversaint - 1 year ago 75
R Question

How to Superimpose Multiple Density Curves Into One Plot in R

I have a data that looks like this.

And I intend to create multiple density curve into one plot, where each curve
correspond to the unique ID.

I tried to use "sm" package, with this code, but without success.

dat <- read.table("mydat.txt");
plotfn <- ("~/Desktop/flowgram_superimposed.pdf");
pdf(plotfn);$V1,dat$V2, xlab = "Flow Signal")
colfill <- c(2:10);
legend(locator(1), levels(dat$V2), fill=colfill);

Please advice what's the right way to do it or if there is
alternative way to do it?

I am trying to get this kind of plot at the end.

Answer Source

Try using ggplot2:

dnow <- read.table("")
qplot(V1, colour=factor(V2), data=dnow, geom="density")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download