hai_winsorized_truncate_augment: Augment Function Winsorize Truncate

View source: R/augment-hai-winsorized-truncate.R

hai_winsorized_truncate_augmentR Documentation

Augment Function Winsorize Truncate

Description

Takes a numeric vector and will return a tibble with the winsorized values.

Usage

hai_winsorized_truncate_augment(.data, .value, .fraction, .names = "auto")

Arguments

.data

The data being passed that will be augmented by the function.

.value

This is passed rlang::enquo() to capture the vectors you want to augment.

.fraction

A positive fractional between 0 and 0.5 that is passed to the stats::quantile paramater of probs.

.names

The default is "auto"

Details

Takes a numeric vector and will return a winsorized vector of values that have been truncated if they are less than or greater than some defined fraction of a quantile. The intent of winsorization is to limit the effect of extreme values.

Value

An augmented tibble

Author(s)

Steven P. Sanderson II, MPH

See Also

https://en.wikipedia.org/wiki/Winsorizing

Other Augment Function: hai_fourier_augment(), hai_fourier_discrete_augment(), hai_hyperbolic_augment(), hai_polynomial_augment(), hai_scale_zero_one_augment(), hai_scale_zscore_augment(), hai_winsorized_move_augment()

Examples

suppressPackageStartupMessages(library(dplyr))

len_out <- 24
by_unit <- "month"
start_date <- as.Date("2021-01-01")

data_tbl <- tibble(
  date_col = seq.Date(from = start_date, length.out = len_out, by = by_unit),
  a = rnorm(len_out),
  b = runif(len_out)
)

hai_winsorized_truncate_augment(data_tbl, a, .fraction = 0.05)


healthyR.ai documentation built on April 3, 2023, 5:24 p.m.