简体   繁体   中英

How to find the x-value given the y-value from a plot in R

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM