capValues takes a numeric vector and returns a vector in which all values greater than a specified maximum are reset to that maximum value.

capValues(DataCol, maxVal = 0.95)

Arguments

DataCol

A vector of numeric values.

maxVal

A numeric value specifying the maximum value or quantile at which to cap all data.

Value

A vector of numeric values where no value is greater than the maximum specified by maxVal.

Details

The maximum may be specified either as a quantile or as a number.

If maxVal is less than one, it is interpreted as a quantile, otherwise it is interpreted as the maximum value to return.

The default value is 0.95, which caps all values in the input at the 95 percent quantile.

Example

x = seq(1,10) y <- capValues(x, 0.75) z <- capValues(x, 5) rbind(x, y, z)

Author

Andi Stephens