[R] good method of removing outliers?

Joshua Wiley jwiley.psych at gmail.com
Fri Dec 30 18:15:08 CET 2011

Hi Michael,

I'm afraid this is one of those cases where the short answer is "No"
and the long answer is, "No."

If you are working with a data set stored in a data frame, something like:

sapply(mtcars, function(x) if (is.numeric(x)) range(x, na.rm = TRUE)
else c(NA, NA))

should give you the range for all numeric variables---which is a
simple check if any values fall outside the possible range (say you
have an age variable with a -3 or 320).  Beyond that, you can inspect
data visually, but ultimately, you have to decide what an outlier is
and justify it.



On Fri, Dec 30, 2011 at 9:03 AM, Michael <comtech.usa at gmail.com> wrote:
> Happy holidays all!
> I know it's very subjective to determine whether some data is outlier or
> not...
> But are there reasonally good and realistic methods of identifying outliers
> in R?
> Thanks a lot!
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles

More information about the R-help mailing list