简体   繁体   中英

Boxplot in R uper/lower whiskers

我正在使用Boxplot的最基本功能,boxplot(x,...,range = 1.5,但如果我不设置范围,则让R使用其默认值。例如boxplot(x,..., )晶须的精确分位数是多少?因为我的轮廓仪大于或小于上/下晶须。我怎么知道上/下晶须在轮廓仪上的确切百分比?换句话说,无需设置范围内,请问上下晶须的数据百分比是多少?

For example, you could calculate the percentage of utliers as follows:

# Some data with outliers:
d <- rnorm(100)
d[sample(1:100, 10)] <- rnorm(10,mean = 0, sd = 10)
bp <- boxplot(d)

# Get the values of the outliers:
out <- bp$out

# The proportion of outliers:
length(out)/length(d)*100
9

Not entirely sure what your question is, but: ?boxplot says the default value of range is 1.5, and then it says

range: this determines how far the plot whiskers extend out from the box. If 'range' is positive, the whiskers extend to the most extreme data point which is no more than 'range' times the interquartile range from the box. A value of zero causes the whiskers to extend to the data extremes.

In other words, the whiskers are not defined as a proportion of the data, but as a multiple of the interquartile range.

If you want to know the proportions, you can use boxplot.stats :

set.seed(101)
x <- runif(100)
bb <- boxplot.stats(x)
 c(mean(x<min(bb$stats)),mean(x>max(bb$stats)))
## [1] 0 0

mean(<logical value>) is a shortcut for computing a proportion. Because I have chosen the data from a uniform distribution, there are actually no points beyond the whiskers (confirmed by looking at boxplot(x) ). If I were to do re-do this with rcauchy() there would be lots ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM