On 04.05.2012 14:34, Johannes Radinger wrote:> Hi,
>
> I have two variables ranging both from 0 to 1 (n=500 each).
> Now I am interested in plotting them both in one plot (using ggplot2).
>
> So far I used ecdf() (from an example I found with google) to get
> values for the cumulatice distribution function which gives a relative
> curve. I also want to do the same plot but using absolute cumulative
> values instead of relative. Can that be done with ecdf or with stepfun()
> to get values I can use to plot the curves?
>
> Here a small example that shows the result with ecdf:
>
> library(ggplot2)
> library(reshape)
>
> dftest1<-
data.frame(value=runif(1000,0,1),variable=rep(c("a","b"),c(500,500)))
> dftest2<- ddply(dftest1,.(variable),transform, ecd = ecdf(value)(value))
>
> ggplot(dftest2,aes(x = value, y = ecd)) +
> geom_line(aes(group = variable,colour = variable))
>
> I'd like to replace the ecdf-function in ddply with a function that
gives cumulative counts resp. the cumulative position of each observation, so
that I get an absolute cumulative curve as a result? Is that understandable?
>
> Thank you very much,
>
> Johannes
What about using stepfun() and providing the data cummulated via cumsum?
Uwe Ligges