[R] Overlay two stat_ecdf() plots
David Winsemius
dwinsemius at comcast.net
Tue Apr 16 19:12:54 CEST 2013
On Apr 16, 2013, at 12:45 AM, PIKAL Petr wrote:
> Hi
>
> Do you mean ecdf? If yes just ose add option in plot.
>
> plot(ecdf(rnorm(100, 1,2)))
> plot(ecdf(rnorm(100, 2,2)), add=TRUE, col=2)
>
> If not please specify from where is ecdf_stat or stat_ecdf which, as you indicate, are the same functions.
It has the appearance of a ggplot2 function, so I think this student has not yet grasped that there needs to be a call to ggplot to set up the dataframework to which `stat_ecdf` will then be "added" (with the overloaded "+" operator) as a layer.
>
> Regrdas
> Petr
>
>
>
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Robin Mjelle
>> Sent: Monday, April 15, 2013 1:10 PM
>> To: r-help at r-project.org
>> Subject: [R] Overlay two stat_ecdf() plots
>>
>> I want to plot two scdf-plots in the same graph.
>> I have two input tables with one column each:
>>
>>> Targets <- read.table("/media/....", sep="", header=T) NonTargets <-
>>> read.table("/media/...", sep="", header=T)
>>
>>> head(Targets)
>> V1
>> 1 3.160514
>> 2 6.701948
>> 3 4.093844
>> 4 1.992014
>> 5 1.604751
>> 6 2.076802
>>
>>> head(NonTargets)
>> V1
>> 1 3.895934
>> 2 1.990506
>> 3 -1.746919
>> 4 -3.451477
>> 5 5.156554
>> 6 1.195109
>>
>>> Targets.m <- melt(Targets)
>>> head(Targets.m)
>> variable value
>> 1 V1 3.160514
>> 2 V1 6.701948
>> 3 V1 4.093844
>> 4 V1 1.992014
>> 5 V1 1.604751
>> 6 V1 2.076802
>>
>>> NonTargets.m <- melt(NonTargets)
>>> head(NonTargets.m)
>> variable value
>> 1 V1 3.895934
>> 2 V1 1.990506
>> 3 V1 -1.746919
>> 4 V1 -3.451477
>> 5 V1 5.156554
>> 6 V1 1.195109
>>
>>
>> How do I proceed to plot them in one Graph using ecdf_stat()
>>
>> [[alternative HTML version deleted]]
>>
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list