winsorize {tidyfinance}R Documentation

Winsorize a Numeric Vector

Description

Replaces the values in a numeric vector that are beyond the specified quantiles with the boundary values of those quantiles. This is done for both tails of the distribution based on the cut parameter.

Usage

winsorize(x, cut)

Arguments

x

A numeric vector to be winsorized.

cut

The proportion of data to be winsorized from both ends of the distribution. For example, a cut of 0.05 will winsorize the lowest and highest 5% of the data. Must be inside [0, 0.5].

Value

A numeric vector with the extreme values replaced by the corresponding quantile values.

Examples

set.seed(123)
data <- rnorm(100)
winsorized_data <- winsorize(data, 0.05)


[Package tidyfinance version 0.1.0 Index]