本文介绍了R中箱线图中的上下四分位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有
X=c(20 ,18, 34, 45, 30, 51, 63, 52, 29, 36, 27, 24)
使用boxplot
,我试图绘制quantile(X,0.25)
和quantile(X,0.75)
但这与R中的箱形图的上下四分位数并不相同
With boxplot
, i'm trying to plot the quantile(X,0.25)
and quantile(X,0.75)
but this is not realy the same lower and upper quartiles in boxplot in R
boxplot(X)
abline(h=quantile(X,0.25),col="red",lty=2)
abline(h=quantile(X,0.75),col="red",lty=2)
你知道为什么吗?
推荐答案
该框的值称为铰链,可能与四分位数重合(由quantile(x, c(0.25, .075))
计算),但计算方式不同.
The values of the box are called hinges and may coincide with the quartiles (as calculated by quantile(x, c(0.25, .075))
), but are calculated differently.
来自?boxplot.stats
:
要查看这些值是否与奇数个观测值一致,请尝试以下代码:
To see that the values coincide with an odd number of observations, try the following code:
set.seed(1234)
x <- rnorm(9)
boxplot(x)
abline(h=quantile(x, c(0.25, 0.75)), col="red")
这篇关于R中箱线图中的上下四分位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!