Matthias Munz
Matthias Munz

Reputation: 3765

R: How to calculate values of 1,5*IQR whiskers

How can I calculate the values of the top and bottom border of 1,5×IQR?

Upvotes: 3

Views: 2299

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368261

You can use the boxplot.stats() function used by boxplot():

R> boxplot.stats(rnorm(100))
$stats
[1] -2.3865817 -0.7195878  0.0889332  0.6237745  2.3702410

$n
[1] 100

$conf
[1] -0.123318  0.301184

$out
numeric(0)

R> 

It is documented to give this:

Value:

 List with named components as follows:

stats: a vector of length 5, containing the extreme of the lower whisker, the lower ‘hinge’, the median, the upper ‘hinge’ and the extreme of the upper whisker.

   n: the number of non-‘NA’ observations in the sample.

conf: the lower and upper extremes of the ‘notch’ (‘if(do.conf)’).
      See the details.

 out: the values of any data points which lie beyond the extremes
      of the whiskers (‘if(do.out)’).
 Note that ‘$stats’ and ‘$conf’ are sorted in _in_creasing order,
 unlike S, and that ‘$n’ and ‘$out’ include any ‘+- Inf’ values.

Upvotes: 7

Related Questions