I have data from three doses of a treatment, with three replicates per each dose:
df <- data.frame(dose=c(rep(1,300),rep(3,300),rep(5,300)),
replicate=rep(c(rep("X1",100),rep("X2",100),rep("X3",100)),3),
value=c(rnorm(300,1,1),rnorm(300,3,1),rnorm(300,5,1)),stringsAsFactors=F)
df$dose <- factor(df$dose,levels=c(1,3,5))
I want to display it using an cdf plot. Per each replicate I can simply plot the cdfs of the three doses with:
for(r in c("X1","X2","X3")){
ggplot(dplyr::filter(df,replicate==r),aes(x=value,color=dose))+
stat_ecdf(geom="step")+
theme_bw()+
theme(panel.border=element_blank(),strip.background=element_blank())
}
But I'm looking for a way to display all replicates of each dose in one figure, with standard error shading around the mean value, similar to plots achieved with stat_smooth
.
Can this be achieved?
Also, either for this or for a single replicate's plot:
r <- "X1"
ggplot(dplyr::filter(df,replicate==r),aes(x=value,color=dose))+
stat_ecdf(geom="step")+
theme_bw()+
theme(panel.border=element_blank(),strip.background=element_blank())
Is there a way to compute the area under each of the ecdfs?