R中我的数据99%点处的垂直线(模拟置信区间)

R中我的数据99%点处的垂直线(模拟置信区间),r,plot,R,Plot,我有一个非常简单的问题,我需要在99%的数据上画一条垂直线,这听起来很简单。经过研究,我发现最方便(我认为)的方法是使用分位数函数。为了简化,我在这里使用90%而不是99%的培训数据: conf_c = c(1,2,3,4,5,6,7,8,9,10) hist(conf_c) abline(v=quantile(conf_c,0.9), col="red") quantile(conf_c, 0.9) 但是这个方法给了我9.1,我要精确到9(90%)。有什么简单的解决办法吗 提前感谢您可以使用

我有一个非常简单的问题,我需要在99%的数据上画一条垂直线,这听起来很简单。经过研究,我发现最方便(我认为)的方法是使用
分位数
函数。为了简化,我在这里使用90%而不是99%的培训数据:

conf_c = c(1,2,3,4,5,6,7,8,9,10)
hist(conf_c)
abline(v=quantile(conf_c,0.9), col="red")
quantile(conf_c, 0.9)
但是这个方法给了我9.1,我要精确到9(90%)。有什么简单的解决办法吗


提前感谢

您可以使用
round
功能,如下所示:

## Your code    
conf_c <- c(1,2,3,4,5,6,7,8,9,10)
hist(conf_c)
abline(v=quantile(conf_c,0.9), col="red")

## Suggestion & output:
cutoff <- quantile(conf_c,0.9)
abline(v=round(cutoff), col="blue")
legend("topleft", legend=c("`quantile`", "`round`"), col=c("red", "blue"), lty=1)
##您的代码

conf_c您可以使用
round
功能,如下所示:

## Your code    
conf_c <- c(1,2,3,4,5,6,7,8,9,10)
hist(conf_c)
abline(v=quantile(conf_c,0.9), col="red")

## Suggestion & output:
cutoff <- quantile(conf_c,0.9)
abline(v=round(cutoff), col="blue")
legend("topleft", legend=c("`quantile`", "`round`"), col=c("red", "blue"), lty=1)
##您的代码

conf_c使用分位数(conf_c,0.9,type=1)
。请参阅
分位数的
类型
小节。好的,谢谢。不知何故,我并没有从分位数描述中得到这一点。使用
分位数(conf_c,0.9,type=1)
。请参阅
分位数的
类型
小节。好的,谢谢。不知怎的,我并没有从分位数描述中得到这个。