trim: Trim Tail Values off of a Vector

Description Usage Arguments Value See Also Examples

View source: R/trim.R

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

1
2
trim(x, p = NULL, tails = "both", cutpoints = NULL,
  keep.edge = TRUE)

Arguments

x

Numeric vector.

p

Numeric value giving tail probability to trim from x. Can leave as NULL if you specify cutpoints.

tails

Numeric value indicating which tail should be trimmed. Possible values are "both", "lower", and "upper".

cutpoints

Numeric vector indicating what range of values should be retained. For example, set to c(0, 1) to trim all values below 0 or greater than 1. Can leave as NULL if you specify p.

keep.edge

Logical value indicating whether values in x that are on the edge of being trimmed (i.e. equal to one of the endpoints) should be retained.

Value

Numeric vector.

See Also

inside

Examples

1
2
3
4
5
6
7
# 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))

dvmisc documentation built on Dec. 18, 2019, 1:35 a.m.