如何删除R中boxplot中的异常值?

时间:2013-01-08 03:22:52

标签: r boxplot outliers

  

可能重复:
  Changing the outlier rule in a boxplot

我需要使用box-plot可视化我的结果。

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

如何在可视化过程中过滤异常值?

(1)这样我就可以在屏幕上显示完整的图像而不会出现丑陋的异常值。

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

(2)有没有办法显示超出一定范围的异常值? http://postimage.org/image/np28oee0b/8251d102/

问候

1 个答案:

答案 0 :(得分:45)

请参阅?boxplot以获取所需的所有帮助。

 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)

为了扩大胡须的范围并抑制此范围内的异常值:

   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)