If I use the ecdfplot()
function of the latticeExtra
package how do I get the actual values calculated i.e. the y-values which correspond to the ~x|g
input?
I've been looking at ?ecdfplot
but there's not discription to it. For the usual highlevel function ecdf()
it works with the command plot=FALSE
but this does not work for ecdfplot()
.
The reason I want to use ecdfplot()
rather than ecdf()
is that I need to calculate the ecdf()
values for a grouping variable. I know I could do this handish too but I'm quite convinced that there is a highroad too.
Here a small expample
u <- rnorm(100,0,1)
mygroup <- c(rep("group1",50),rep("group2",50))
ecdfplot(~u, groups=mygroup)
I would like to extract the y-values given each group for the corresponding x-values.
If you stick with the ecdf() function in the base package, you can simply do as follows:
Create ecdf function with your data:
fun.ecdf <- ecdf(x) # x is a vector of your data
Now use this "ecdf function" to generate the cumulative probabilities of any vector you feed it, including your original, sorted data:
my.ecdf <- fun.ecdf(sort(x))