Skip to contents

Takes a numeric vector and will return a vector that has been scaled by mean and standard deviation

Usage

hai_scale_zscore_augment(.data, .value, .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.

.names

This is set to 'auto' by default but can be a user supplied character string.

Value

An augmented tibble

Details

Takes a numeric vector and will return a vector that has been scaled by mean and standard deviation.

The input vector must be numeric. The computation is fairly straightforward. This may be helpful when trying to compare the distributions of data where a distribution like beta from the fitdistrplus package which requires data to be between 0 and 1

$$y[h] = (x - mean(x) / sd(x))$$

This function is intended to be used on its own in order to add columns to a tibble.

Author

Steven P. Sanderson II, MPH

Examples

df <- data.frame(x = mtcars$mpg)
hai_scale_zscore_augment(df, x)
#> # A tibble: 32 × 2
#>        x hai_scale_zscore_x
#>    <dbl>              <dbl>
#>  1  21                0.151
#>  2  21                0.151
#>  3  22.8              0.450
#>  4  21.4              0.217
#>  5  18.7             -0.231
#>  6  18.1             -0.330
#>  7  14.3             -0.961
#>  8  24.4              0.715
#>  9  22.8              0.450
#> 10  19.2             -0.148
#> # ℹ 22 more rows