本文介绍了如何在R中的图上找到给定y值的x值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用R 3.4.3,并绘制以下函数:
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:
现在,该图未采用给定的标签x0和y0.该如何解决?
Now, the plot doesn't take the given labels x0 and y0. How to solve this?
此外,如何获得y = 0.95的x值.我尝试使用标签名称,但是会引发错误.请提出.
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.
推荐答案
标签的参数为xlab
和ylab
(在这两个标签中都添加了额外的s
):
The arguments for the labels are xlab
and ylab
(you added an extra s
in both):
要找到x
的y
为0.95,可以执行以下操作:
To find x
for a y
of 0.95 you can do:
x[which(cdf_1(x) == 0.95)]
#[1] 68.38452
这篇关于如何在R中的图上找到给定y值的x值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!