How to remove/eliminate outliers using IQR method

GeoBar

I'm quite a beginner with R and R packages in general. I'd like to ask you if there is any clear solution to the problem below. I've imported my data in .csv format as you can see in the following picture

https://dl.dropboxusercontent.com/u/23801982/1234.jpg

These are grouped data by entity year month and are about the 4 parameters as you can see in the next columns. If also produce a box plot for the e.g. Absrtactions column as following:

https://dl.dropboxusercontent.com/u/23801982/1234566.jpg

Now I'm trying to identify the outliers which I did with boxplot.stats command.

But I don't know how to eliminate exclude the outliers from the results and export them in a new file (e.g. .txt or .csv) due to grouped data. I saw also a manual external way to calculate with IQR but I think it doesn't fit to the exportable dataset required.

The code I used so far is:

rm(list = ls())
library("gdata")

s1 <- read.csv("C:\\Users\\G\\Documents\\R\\Projects\\20141125.csv", header = T)

boxplot(s1$Abstractions ~ s1$Entity, col="green", srt=45) 

boxplot.stats(s1$Abstractions)

Thank you

biobirdman

You are looking at the right function boxplot.stats

to look at what a function in R you can use

?functionName

so try

?boxplot.stats

and you will see that it return the outliers values in a slot call out

Value:

     List with named components as follows:

   stats: a vector of length 5, containing the extreme of the lower
          whisker, the lower ‘hinge’, the median, the upper ‘hinge’ and
          the extreme of the upper whisker.

       n: the number of non-‘NA’ observations in the sample.

    conf: the lower and upper extremes of the ‘notch’ (‘if(do.conf)’).
          See the details.

     out: the values of any data points which lie beyond the extremes
          of the whiskers (‘if(do.out)’).
     Note that ‘$stats’ and ‘$conf’ are sorted in _in_creasing order,
     unlike S, and that ‘$n’ and ‘$out’ include any ‘+- Inf’ values.

so to remove the outliers you can do something like this

outliersValue<- boxplot.stats(x)$out
x[!x %in% outliersValue]

where x is your data .

the %in% operator will check if a value exist in another value. Adding ! is a negation operator , which this case, will reverse the logic, returning True for x that are not found in outliersValue

I hope you find this useful. Happy R-ing

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How to properly remove outliers for specific list elements in r?

来自分类Dev

查找行组的IQR

来自分类Dev

How to return a NULL from a templated method, without using a pointer

来自分类Dev

How do I mock a method call inside the method I want to test using NUnit?

来自分类常见问题

您如何在Numpy中找到IQR?

来自分类Dev

中断IQR和XIRQ-组装

来自分类Dev

基于IQR按组去除离群值

来自分类Dev

Using sum method in LINQ

来自分类Dev

How to bind a button on wpf grid to a method on MVVM when I am using caliburn micro

来自分类Dev

How do I get the each method to work with multiple inputs using MagicSuggest?

来自分类Dev

Using classList method in square brackets

来自分类Dev

如果在IQR之外,请删除列表中的项目

来自分类Dev

如何使用IQR方法删除/消除异常值

来自分类Dev

通过将Stata中的IQR除以变量来创建变量

来自分类Dev

如何在IQR内的熊猫中对列值进行上限

来自分类Dev

如果在IQR之外,请删除列表中的项目

来自分类Dev

循环列并按组计算IQR的最快方法,然后根据参考组计算每个组的比例IQR?

来自分类Dev

Removing Spatial Outliers (lat and long coordinates) in R

来自分类Dev

Updating Python Tkinter GUI using .after method

来自分类Dev

Invalid character error while using atob() method

来自分类Dev

How to manage GET Method in an API

来自分类Dev

How to call method within builder

来自分类Dev

How to manage a mutex in an asynchronous method

来自分类Dev

How to use the trace method in Flambe?

来自分类Dev

Java generic method - how to make it call a specialized method

来自分类Dev

How to call a varargs method with an additional argument from a varargs method

来自分类Dev

如何使用IQR中的值替换多个变量和个体的异常值

来自分类Dev

找不到我的数据集的异常值(更确切地说是IQR)

来自分类Dev

胡须被定义为 1.5* IQR,python seaborn boxplot 中的两个胡须如何不同?

Related 相关文章

  1. 1

    How to properly remove outliers for specific list elements in r?

  2. 2

    查找行组的IQR

  3. 3

    How to return a NULL from a templated method, without using a pointer

  4. 4

    How do I mock a method call inside the method I want to test using NUnit?

  5. 5

    您如何在Numpy中找到IQR?

  6. 6

    中断IQR和XIRQ-组装

  7. 7

    基于IQR按组去除离群值

  8. 8

    Using sum method in LINQ

  9. 9

    How to bind a button on wpf grid to a method on MVVM when I am using caliburn micro

  10. 10

    How do I get the each method to work with multiple inputs using MagicSuggest?

  11. 11

    Using classList method in square brackets

  12. 12

    如果在IQR之外,请删除列表中的项目

  13. 13

    如何使用IQR方法删除/消除异常值

  14. 14

    通过将Stata中的IQR除以变量来创建变量

  15. 15

    如何在IQR内的熊猫中对列值进行上限

  16. 16

    如果在IQR之外,请删除列表中的项目

  17. 17

    循环列并按组计算IQR的最快方法,然后根据参考组计算每个组的比例IQR?

  18. 18

    Removing Spatial Outliers (lat and long coordinates) in R

  19. 19

    Updating Python Tkinter GUI using .after method

  20. 20

    Invalid character error while using atob() method

  21. 21

    How to manage GET Method in an API

  22. 22

    How to call method within builder

  23. 23

    How to manage a mutex in an asynchronous method

  24. 24

    How to use the trace method in Flambe?

  25. 25

    Java generic method - how to make it call a specialized method

  26. 26

    How to call a varargs method with an additional argument from a varargs method

  27. 27

    如何使用IQR中的值替换多个变量和个体的异常值

  28. 28

    找不到我的数据集的异常值(更确切地说是IQR)

  29. 29

    胡须被定义为 1.5* IQR,python seaborn boxplot 中的两个胡须如何不同?

热门标签

归档