## generate data
set.seed(1234) # for reproducibility
x <- rnorm(10) # standard normal
x[1] <- x[1] * 10 # introduce outlier
## Trim data
x
Trim(x, trim=0.1)
## Trim fixed number, say cut the 3 extreme elements from each end
Trim(x, trim=3)
## check function
s <- sample(10:20)
s.tr <- Trim(s, trim = 2)
setequal(c(s[attr(s.tr, "trim")], s.tr), s)
Run the code above in your browser using DataLab