trim: (Trimmed) vector.

Description Usage Arguments Value Examples

View source: R/trim.R

Description

Find a vector excluding trimmed values, on which the calculation of a statistic will result in a trimmed statistic.

Usage

1
trim(x, trim = 0, na.rm = FALSE, ...)

Arguments

x

A numeric vector of real values.

trim

The fraction (0 to 0.5) of observations to be trimmed from each end of x.

na.rm

A logical value indicating whether NA values should be stripped.

...

Further arguments passed to or from other methods.

Value

If trim is zero (the default), the values in x is returned. If x is not logical (coerced to numeric), numeric (including integer) or complex, NA_real_ is returned, with a warning. If trim is non-zero, a symmetrically trimmed vector is returned with a fraction of trim observations deleted from each end.

Examples

1
2
3
4
5
6
x <- c(rnorm(100), 100)
mean(x)
mean(x, trim=0.01)
mean(trim(x, trim=0.01))
sd(x)
sd(trim(x, trim=0.01))

alR documentation built on Dec. 7, 2017, 5:03 p.m.

Related to trim in alR...