[R] Two ecdf with log-scales
David Winsemius
dwinsemius at comcast.net
Wed May 2 16:16:51 CEST 2012
On May 2, 2012, at 6:14 AM, Johannes Radinger wrote:
> Hi,
>
> i want to plot empirical cumulative density functions for two
> variables in
> one plot. For better visualizing the differences in the two
> cumulative curves I'd like to log-scale the axis.
>
> So far I found 3 possible functions to plot ecdf:
>
> 1) ecdf() from the package 'stats'. I don't know how to successfully
> set the log.scales? Combining two plots is not a problem:
>
> plot(ecdf(x1))
> lines(ecdf(x2),col.h="red")
>
> 2) gx.ecdf() from package 'rgr'. It is easily possible to plot log-
> scales, but I don't know how to plot two densities?
>
> gx.ecdf(x1,log=TRUE,ifqs = TRUE)
>
> 3) Ecdf() from package 'Hmisc'. No log-option directly available and
> here I also don't know how to 'stack' two plots...
>
> Ecdf(x1,what="F")
>
>
> Probably there are many more solutions (e.g. ggplot etc.)...
> ...Has anyone faced a similar task and found a simple solution? Any
> suggestions are welcome!
Have you searched the Archives? I seem to remember that the log(0) was
a barrier to persons attempting this in the past. (ISTR a posting in
the last few weeks.) Maybe you could also provide a test data object
that has the same range as your x1 and x 2 variables.
> and provide commented, minimal, self-contained, reproducible code.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list