trim {dvmisc} | R Documentation |
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.
trim(x, p = NULL, tails = "both", cutpoints = NULL,
keep.edge = TRUE)
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 |
Numeric vector.
# 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))