2

The lower whisker is defined by Q1 - c * IQR and the upper whicker by Q3 + c * IQR

being Q1 - first quartile, Q3 - third quartile, IQR - inter quartile range, and C a variable. Usually C is 1.5, and I'm not sure, but probably is default for boxplot().

Is it possible to specify this C value when creating a boxplot?

Solutions using ggplot2 are welcome too.

  • You have not told us what the data is, but are negative values possible or do they represent some kind of coding for missing data? – dcarlson Apr 27 '21 at 21:48
  • I would recommend this post for that: https://stackoverflow.com/questions/4787332/how-to-remove-outliers-from-a-dataset. I am also pretty sure you should take @dcarlson 's suggestion seriously. – GuedesBF Apr 27 '21 at 22:51
  • @dcarlson I am sorry you are right. After reviewing my question, i think that the context i gave isn't really needed for the problem, and it was misleading, so i decided to remove it. – Zé Miguel Coutinho Apr 27 '21 at 23:26

1 Answers1

3

I found the answer. Completely missed it reading the documentation, sorry.

It can be given as an argument in boxplot():

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.

boxplot(x,...,range=2)

Edit: as tjebo suggested, this post (In ggplot2, what do the end of the boxplot lines represent?) completes the answer. Altough the title has ggplot2, it mentions the solution to my problem and might be worth checking out.

  • Ze, thanks for sharing, and good job answering your own question. +1 Although this was a duplicate question (see my flag) - please don't delete it. It will be useful for others for their future searches. – tjebo Apr 28 '21 at 07:14
  • 1
    @tjebo Thank you for your suggestion! Altough the title meantions ggplot2, it uses the boxplot() function and has an explanation of the outlier-whisker relation and what defines a whisker too. Ill had add the link to my answer so people can check it out – Zé Miguel Coutinho Apr 28 '21 at 19:33