Learn R Programming

tidyfinance (version 0.4.3)

trim: Trim a Numeric Vector

Description

Removes the values in a numeric vector that are beyond the specified quantiles, effectively trimming the distribution based on the cut parameter. This process reduces the length of the vector, excluding extreme values from both tails of the distribution.

Usage

trim(x, cut)

Value

A numeric vector with the extreme values removed.

Arguments

x

A numeric vector to be trimmed.

cut

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

Examples

Run this code
set.seed(123)
data <- rnorm(100)
trimmed_data <- trim(x = data, cut = 0.05)

Run the code above in your browser using DataLab