Trim certain proportion of the most extreme values in a numeric vector.

trim(y, trim = 0.1, na.rm = FALSE, ...)

Arguments

y

A numeric vector

trim

(number) A proportion of values to be removed. A number between 0 and 1. Default is 0.1.

na.rm

(logical) if TRUE, any NA and NaN's are removed from y before quantiles are computed.

...

further argument to stats::quantile().

Value

A trimmed vector.

Examples

1:10
#> [1] 1 2 3 4 5 6 7 8 9 10
# [1] 1 2 3 4 5 6 7 8 9 10 trim(1:10)
#> [1] 2 3 4 5 6 7 8 9
# [1] 2 3 4 5 6 7 8 9 trim(1:10, trim = 0.4)
#> [1] 3 4 5 6 7 8
# [1] 3 4 5 6 7 8