Created
May 12, 2016 17:35
-
-
Save TrevorMcCormick/1fec629451d96222aa5166f128e528d9 to your computer and use it in GitHub Desktop.
R Function to remove outliers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_outliers <- function(x, na.rm = TRUE, ...) { | |
qnt <- quantile(x, probs=c(.25, .75), na.rm = na.rm, ...) | |
H <- 1.5 * IQR(x, na.rm = na.rm) | |
y <- x | |
y[x < (qnt[1] - H)] <- NA | |
y[x > (qnt[2] + H)] <- NA | |
y | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment