ptrim: Trims the top percentile of values from a vector.

Description Usage Arguments Details Value Examples

View source: R/ptrim.R

Description

Because precipitation is heavy-tailed, the process of constructing a distribution mapping (a distmap object) for precipitation tends to overfit the upper tails. To avoid this problem, it is useful in this case to trim extreme values from the input datasets. This function discards the top p% of values from the input vector.

Usage

1
ptrim(x, p = 0.01, ...)

Arguments

x

a vector of values.

p

the percentage of values to discard. Defaults to 1%.

...

further arguments passed on to stats::quantile

Details

This function uses the stats::quantile function to find a cutoff value. Because any quantile with probability less than 1 is always less than the maximum value, the function will always trim the maximum value from x.

Value

The input vector x with the top p percent of values (minimum 1) removed.

Examples

1
2
3
4
5
set.seed(222)
x <- c(rnorm(20), 2, 5, 10, 50, 100)
print(x)
print(ptrim(x, p=0.10))
print(quantile(x, p=0.9))

sethmcg/climod documentation built on Nov. 19, 2021, 11:12 p.m.