【问题标题】:How to remove outliers in boxplot in R? [duplicate]如何删除R中箱线图中的异常值? [复制]
【发布时间】:2012-12-21 21:04:37
【问题描述】:

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

我需要使用箱线图来可视化我的结果。

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

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

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

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

(2) 有什么方法可以显示一定范围内的异常值? http://postimage.org/image/np28oee0b/8251d102/

问候

【问题讨论】:

    标签: r boxplot outliers


    【解决方案1】:

    请参阅 ?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)
    

    【讨论】:

    • 我可以使用范围仅在一侧扩展异常值吗(对于有偏差的数据)。
    • @user15662 - 我不知道使用基本 R 图形。
    • @user15662:您可以绘制没有异常值的箱线图并保存结果 (foo &lt;- boxplot(x,horizontal=TRUE,ylim=c(-4,4),outline=FALSE)),然后添加正异常值 (points(foo$out[foo$out&gt;0],rep(1,sum(foo$out&gt;0))))。这不会延长胡须,但这有帮助吗?
    • 谁能解释一下为什么去掉异常值的设置叫做outline??
    • @normanius - 我认为这是对 S 的回归,R 是其方言。 S 语言使用outline= 作为将异常值绘制为线的参数。请参阅此处以获取带有异常线的 S 箱线图示例 - statland.org/Software_Help/SPLUS/PulseSP1.htm 和此处以获取 S 箱线图函数的手册页 - uni-muenster.de/ZIV.BennoSueselbeck/s-html/helpfiles/…
    猜你喜欢
    • 1970-01-01
    • 2019-05-21
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 2021-01-14
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    相关资源
    最近更新 更多