I'm working with a dataset of elemental concentrations, and I want to compare the cumulative frequency graphs of elemental concentrations in two places, like I did using plot() in this image, but with ggplot. Here is a dummy dataset
df<-data.frame("Zone"=c(rep("A",10),rep("B",9)),"Con"=c(rnorm(10,5,2),rnorm(9,7,2.5)))
I've managed to make a cumulative frequency graph for both zones together in this clumsy way:
ggplot(df,aes(x=cumsum(rep(1,19)),y=sort(Con)))+geom_point()
But I can't figure out how to make it for both zones separately. Thanks in advance.
I think you'd like to use stat_ecdf
from ggplot2:
ggplot(df, aes(Con, color = Zone)) + stat_ecdf(geom = "point")