trim {dvmisc} | R Documentation |
Trim Tail Values off of a Vector
Description
Returns input vector with tail values trimmed off of it. User can specify tail probability to trim or lower and upper cutpoints for values to retain.
Usage
trim(x, p = NULL, tails = "both", cutpoints = NULL,
keep.edge = TRUE)
Arguments
x |
Numeric vector. |
p |
Numeric value giving tail probability to trim from |
tails |
Numeric value indicating which tail should be trimmed. Possible
values are |
cutpoints |
Numeric vector indicating what range of values should be
retained. For example, set to |
keep.edge |
Logical value indicating whether values in |
Value
Numeric vector.
See Also
Examples
# Generate data from N(0, 1) and then trim the lower and upper 1\%
x <- rnorm(1000)
y <- trim(x, p = 0.01)
# Generate data from N(0, 1) and then trim values outside of (-1.5, 1.5)
x <- rnorm(100000)
y <- trim(x, cutpoints = c(-1.5, 1.5))
[Package dvmisc version 1.1.4 Index]