mask_extreme: Replace extreme values by NA

View source: R/mask_extreme.R

mask_extremeR Documentation

Replace extreme values by NA

Description

Compute quantiles of the input data and replace data beyond a given quantile by NA.

Usage

mask_extreme(x, percent = c(0.5, 0.5))

Arguments

x

a numeric vector.

percent

a vector of length 2 containing the percentage of data to replace by NA at the low end and at the high end of x. If percent contains only one number, this percentage is removed at both ends.

Value

The input vector with NA where the extreme were.

Examples

x <- rgamma(1000, 1, 1)
hist(x)
# remove 0.5% at both ends
hist(mask_extreme(x))
# remove at the high end (shorten the long tail)
hist(mask_extreme(x, c(0,1)))
# remove at the low end (little change)
hist(mask_extreme(x, c(1,0)))

jiho/morphr documentation built on May 11, 2024, 9:32 p.m.