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

ε祈祈猫儿з 提交于 2019-12-08 10:07:00

问题


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


来源:https://stackoverflow.com/questions/48205568/how-to-find-the-x-value-given-the-y-value-from-a-plot-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!