Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fcbarbi committed Nov 17, 2015
1 parent 26809e5 commit 5a0a20b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ adjvalues <- function( values ){
value <- sapply( values, adjvalue, simplify = TRUE)
as.vector( value )
}
adjvalue <- function(v) {
if (!is.numeric(v)) {
v <- gsub("\\.",'',v )
Expand All @@ -57,3 +56,26 @@ adjvalue <- function(v) {
}
```

### remove_outliers( num, na.rm = TRUE, ... )
Remove outlier values, those below 1% and above 99% quantiles, from a numeric vector.

Example:
```
set.seed(123)
x <- rnorm(100)
x <- c(-10, x, 10)
y <- remove_outliers(x)
par(mfrow = c(1, 2))
boxplot(x)
boxplot(y)
```
Implementation:
```
remove_outliers <- function(x, na.rm = TRUE, ...) {
qnt <- quantile(x, probs=c(.01, .99), na.rm = na.rm, ...)
y <- x
y[x < qnt[1]] <- NA
y[x > qnt[2]] <- NA
y
}
```

0 comments on commit 5a0a20b

Please sign in to comment.