[R] Plot 2 ecdf in one graph

Rolf Turner r.turner at auckland.ac.nz
Mon Sep 7 04:29:18 CEST 2009


Two things:

(1) type="l" won't work; plot.ecdf() calls plot.stepfun() and it  
doesn't have a ``type'' argument.

(2) Giving plot two separate objects to plot makes no sense at all.

(3) If you've got ***frequency*** data then ecdf() is probably not  
the right thing to do
     in the first place.

(4) I can't count.

To get the ***plots** you want, do something like:

	plot(ecdf(x.pre),do.points=FALSE,col="red",xlim=range(x.pre,x.obs))
	plot(ecdf(x.obs),do.points=FALSE,col="blue",add=TRUE)

But as I said if x.obs and x.pre are counts, rather than the raw  
data, this
does not appear to make any sense.  You are getting the ecdf-s of the  
counts
rather than of the raw data which is a toadally different story.  And  
toadally
misleading.  Re-think.

	cheers,

		Rolf Turner

On 7/09/2009, at 1:52 PM, Roslina Zakaria wrote:

> Hi r-users,
>
> I would like to compare the cdf between historical and predicted.  
> My x.obs and x.pre are the frequency data in classes of 0-300.
> I tried:
>
> plot(ecdf(x.obs),ecdf(x.pre),type="l",col="red")
>
> and it gives me:
>
> Error in plot.stepfun(x, ..., ylab = ylab, verticals = verticals,  
> pch = pch) :
>   argument 4 matches multiple formal arguments
>
> Thank you so much for any help given.

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list