How to find the x-value given the y-value from a p

2019-06-14 07:43发布

问题:

I am using R 3.4.3, and plotting the following function:

x =  rnorm(5000,20,30)
cdf_1 <- ecdf(x)  
plot(cdf_1, xlabs="x0",  
     ylabs="y0")

This gives me the following plot:

Now, the plot doesn't take the given labels x0 and y0. How to solve this?

Also, how do I get the value of x for y=0.95. I have tried using label names, but it throws error. Kindly suggest.

回答1:

The arguments for the labels are xlab and ylab (you added an extra s in both):

To find x for a y of 0.95 you can do:

x[which(cdf_1(x) == 0.95)]
#[1] 68.38452


标签: r plot labels