34

Possible Duplicate:
Changing the outlier rule in a boxplot

I need to visualize my result using box-plot.

x<-rnorm(10000)
boxplot(x,horizontal=TRUE,axes=FALSE)

How can i filter outliers during visualisation?

(1) So that i can have full image on screen without having ugly outliers.

http://postimage.org/image/szzbez0h1/a610666d/

(2) Is there any way to show outliers upto certain range? http://postimage.org/image/np28oee0b/8251d102/

Regards

Community
  • 1
  • 1
Manish
  • 3,341
  • 15
  • 52
  • 87

1 Answers1

58

See ?boxplot for all the help you need.

 outline: if ‘outline’ is not true, the outliers are not drawn (as
          points whereas S+ uses lines).

boxplot(x,horizontal=TRUE,axes=FALSE,outline=FALSE)

And for extending the range of the whiskers and suppressing the outliers inside this range:

   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.

# change the value of range to change the whisker length
boxplot(x,horizontal=TRUE,axes=FALSE,range=2)
thelatemail
  • 91,185
  • 12
  • 128
  • 188
  • 2
    Can i extend outliers at only one side using range (for biased data). – Manish Jan 08 '13 at 04:01
  • @user15662 - not that I know of using base R graphics. – thelatemail Jan 08 '13 at 04:06
  • 1
    @user15662: you could plot the boxplot without outliers and save the result (`foo <- boxplot(x,horizontal=TRUE,ylim=c(-4,4),outline=FALSE)`), then add positive outliers (`points(foo$out[foo$out>0],rep(1,sum(foo$out>0)))`). This does not extend the whiskers, but would that help? – Stephan Kolassa Jan 08 '13 at 07:44
  • 5
    Can anyone explain to me why the setting to remove outliers is called _outline_?? – normanius Mar 16 '18 at 13:26
  • @normanius that's an interesting question. – Scientist Aug 17 '18 at 13:46
  • 1
    @normanius - I think it's a throwback to S, which R is a dialect of. The S language used `outline=` as the argument for drawing outliers as lines. See here for an example of an S boxplot with the outlier lines - http://statland.org/Software_Help/SPLUS/PulseSP1.htm and here for the manual page for S' boxplot function - https://www.uni-muenster.de/ZIV.BennoSueselbeck/s-html/helpfiles/boxplot.html – thelatemail Aug 17 '18 at 21:18