1

Suppose I have the following data set

data <- c(
9.5, 27.9, 7.8, 17.8, 31.4, 25.9, 27.4, 
25.2, 31.1, 34.7, 42, 29.1, 32.5, 30.3, 33, 33.8, 41.1, 34.5, 62)

When I drew the boxplot in r

boxplot(data)

I got three outliers 7.8, 9.5, and 62, that are illustrated in the diagram with three small circles.

Here I want to change the pch of the biggest outlier, i.e., 62, to a filled circle, but not the other two smaller outliners.

The following is what I've tried, but it doesn't work:

boxplot(data, outpch = ifelse(data >= 60, 16, 1))

Is there a way to achieve this? Thanks

Likan Zhan
  • 1,056
  • 6
  • 14

1 Answers1

0

I don't think you can do this directly in boxplot function since outpch parameter in boxplot doesn't expect a vector but we can use the points function to display the outliers differently.

bp <- boxplot(data, outpch = NA) 
with(bp, points(group, out, pch = ifelse(out >=60, 16, 1))) 

enter image description here

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213