5

Instead of R's own boxplot() the outliers are missing when using gap.boxplot() from the plotrix package. I try to understand why.

See this example please:

> mtcars[2,c('mpg')] <- 45
> mtcars[6,c('mpg')] <- 77

Using boxplot(mtcars$mpg) you can see two extra dots (the outliers) on top of the boxplot.

R's own <code>boxplot()</code>

Using gap.boxplot(mtcars$mpg) from plotrix package result in that graphic

enter image description here

The big question is why and how to solve this?

d.b
  • 32,245
  • 6
  • 36
  • 77
buhtz
  • 10,774
  • 18
  • 76
  • 149

1 Answers1

4

I have found a workaround to get the outliers. It involves accessing the value of outliers from the gap.boxplot command. Looks like the value of outliers are being computed but not plotted. I am curious to find out why it is happening.

gap.boxplot(mtcars$mpg)
outliers = gap.boxplot(mtcars$mpg)$out
points(x = rep(1,length(outliers)), y = c(outliers))
d.b
  • 32,245
  • 6
  • 36
  • 77
  • 2
    Good job with the workaround. This looks like a bug to me: I would suggest/encourage contacting the maintainer (`maintainer("plotrix")`) and letting them know – Ben Bolker Jan 04 '17 at 16:11
  • 1
    The maintainer is informed and he offered new code. It will be fixed in the next update. – buhtz Jan 07 '17 at 21:33