[R] ecdf plots, lines, and y values

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jun 3 21:36:48 CEST 2004

Monica Palaseanu-Lovejoy wrote:
> Hi,
> I have a question for the group, perhaps someone can help me 
> figure this out.  I've already looked in the help files and they were 
> no help to me.  
> I have a vector of values and I am plotting an ecdf graph. 
> 1. How can i draw a continuous line through the ecdf points? (lines 
> and type for the plot with an ecdf object does not work)

Well, the help page ?plot.ecdf and ?plot.stepfun is pretty clear and 
tells us to use verticals = TRUE.
 From the help page:

   F10 <- ecdf(rnorm(10))
   plot(F10, verticals = TRUE, do.p = FALSE)

> 2. Supposing I have this line drawn. I can add a vertical line of a 
> known x value which intersects the graph. How can I determine the 
> y value of the graph point that is intersected by the abline? 

Use knots(), e.g. by extending the former example as follows:

   kF10 <- knots(F10)
   sum(kF10 <= x) / length(kF10)

Uwe Ligges

> Any help would be appreciated.
>     Thanks in advance,
>     Monica
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

More information about the R-help mailing list