如何在数据框箱图中获取离群值的索引? [英] How to get indices of outliers in a dataframe boxplot?

查看:60
本文介绍了如何在数据框箱图中获取离群值的索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据框,我想获取离群值索引的每一列.

I have a dataframe and I want to get each columns of outliers indices.

这是我数据框的一部分;

Here is part of my dataframe;

mediamarkt [,48]

[1]  7126  4012  3711  3237  3432  2671  2861  7065  3158  4023  4770  3861
[13]  4108  7408  9071  3596  3889  4093  4446  6059  8345 10291  5546  5129
[25]  4683  4670  5694  8619 11047  5743  5775  5216  5283  4854  7871  9944
[37]  3797  3821  3834  3999  4577  8898 11396  4508  5459  3668  3885  4021
[49]  7491  8831  3513  3606  3332  3189  3656  6859  9167  3306  3305  3379
[61]  3507  3912  6562  8245  3420  3445  3530  3404  3847  7187  9128  3623
[73]  3581  3401  2784  3024  6342  7835  2766  2718  2578  2591  2737  5479
[85]  7064  2528  2550  2287  1893  1846

首先,我尝试使用以下代码获取异常值:

First of all I have tried to get value of outliers with this codes:

boxplot(mediamarkt [,48])$ out ,我得到2个离群值;

boxplot(mediamarkt[,48])$out and I get 2 outliers;

[1] 11047 11396

到目前为止,一切都还不错,但是当我需要使用以下代码获取离群值的索引时:

Everything is okey so far but when I need to get indices of outliers with these code below:

which(mediamarkt [,48]%in%boxplot_mediamarkt $ out)

[1] 5 18 29 43 59

我得到2个以上的异常值,与这些结果不匹配

I get more than 2 outliers, it does not match these results

我的代码有什么问题

有人可以帮助我解决我的问题吗?

Could anyone help me about solve my problem?

推荐答案

@ G5W提出了一个仍未解决的问题.该代码显示了如何轻松地对数据进行输入,并建议您 boxplot_mediamarkt 不是数据中 boxplot boxplot.stats 的输出

@G5W has asked a question that remains open. This code shows how to do easy input for your data and suggests that your boxplot_mediamarkt is not the output of boxplot or boxplot.stats from your data.

 dat <- scan()
1:   7126  4012  3711  3237  3432  2671  2861  7065  3158  4023  4770  3861
13:  4108  7408  9071  3596  3889  4093  4446  6059  8345 10291  5546  5129
25:  4683  4670  5694  8619 11047  5743  5775  5216  5283  4854  7871  9944
37:  3797  3821  3834  3999  4577  8898 11396  4508  5459  3668  3885  4021
49:  7491  8831  3513  3606  3332  3189  3656  6859  9167  3306  3305  3379
61:  3507  3912  6562  8245  3420  3445  3530  3404  3847  7187  9128  3623
73:  3581  3401  2784  3024  6342  7835  2766  2718  2578  2591  2737  5479
85:  7064  2528  2550  2287  1893  1846
91: 
Read 90 items
> boxplot(dat)$out
[1] 11047 11396
> which(dat %in% boxplot(dat)$out)
[1] 29 43

这篇关于如何在数据框箱图中获取离群值的索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆