【问题标题】:List Outliers per Variable in Dataframe列出数据框中每个变量的异常值
【发布时间】:2013-08-27 21:37:39
【问题描述】:

我有一个包含 8 个变量的数据框 (x1, x2.. x8)

我想使用以下方法获取箱线图的异常值:

boxplot(dataframe, plot=FALSE)$out

我想要的输出是让数据框列出每个变量的异常值。如下:

variable outlier
x1       outlier1 from x1
x1       outlier2 from x1
x1       outlier3 from x1
x1       outlier4 from x1
x2       outlier1 from x2
x2       outlier2 from x2
x2       outlier3 from x2
.
.
.
x8       outliern from x8

感谢您的支持,

【问题讨论】:

    标签: r dataframe boxplot outliers


    【解决方案1】:

    这是你想要的吗?

    > testdata <- data.frame(x1=runif(1e3),x2=rnorm(1e3),x3=rnorm(1e3))
    > temp <- boxplot(testdata,plot=F)
    > cbind(temp$group,temp$out)
          [,1]      [,2]
     [1,]    2  2.765277
     [2,]    2  2.754730
     [3,]    2 -2.714811
     [4,]    2  3.257889
     [5,]    3  2.605549
     [6,]    3 -3.261950
     [7,]    3 -3.057532
     [8,]    3  2.820352
     [9,]    3  2.602933
    [10,]    3  2.580897
    [11,]    3  2.899350
    

    【讨论】:

      猜你喜欢
      • 2022-08-19
      • 2022-01-22
      • 2015-06-21
      • 2019-12-06
      • 2020-09-16
      • 1970-01-01
      • 2013-01-13
      • 2020-05-22
      • 2017-10-01
      相关资源
      最近更新 更多