How to present a boxplot that does not show outliers separately

26 Views Asked by At

How can I represent the boxplot so that it does not show the outliners separately as points, but treats them as non-outlier data? I don't mean outline=FALSE, because then I can only see outliner data not considered as outliers. enter image description here enter image description here

I would like to ask for help in getting the boxplots so that R does not assume in advance how to willy-nilly calculate them, but so that I can do it afterwards.

1

There are 1 best solutions below

0
Rui Barradas On

Set argument range to zero to extend the whiskers to the data extremes. From help("boxplot"), my emphasis:

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.

data <- c(57, 24.05, 31.09, 181, 18.06, 4.72,  27.6, 325.00, 
         17.14, 0.03, 0.03, 21,2, 9.62, 0.03, 131.15, 3.90, 592, 0.03)

boxplot(data, main = "with outliers")

boxplot(data, range = 0, main = "without outliers")

Created on 2024-03-17 with reprex v2.1.0