图表第95百分位数

时间:2012-05-18 14:19:28

标签: r

我有一个时间序列数据可以使用:

绘图
plot(x$numbers, type="l", col="blue")

我喜欢得到第95百分位并将此第95百分位数添加到此图

x_percent<-quantile(x$numbers, 0.95)

如何将x_percent添加到现有的x $ numbers图表中?

x$numbers<-c(1,2,3,8,10,30)
x$percent<-quantile(x$numbers, 0.95)
plot(x$numbers, type="l")

在这里,我想将x $百分比添加到图表中,基本上绘制一个值为95百分位值的垂直线。 安迪的想法?

1 个答案:

答案 0 :(得分:2)

好的,你的编辑没什么帮助,但我猜你想要做这样的事情......(见Justins评论)

x   <- seq(0,20,length=1000)
y   <- dnorm(x,mean=10, sd=3)
plot(x,y, type="l", lwd=2)
abline(a=1,b=1,v=1,lty=3)

但是你提到的时间序列让我觉得你不确定你在绘制什么。否则,您只需在特定日期标记abline

enter image description here

PS我猜你确实想要x轴另一侧的线

相关问题