z_scale: Z-standardize numeric, continuous variables

z_scaleR Documentation

Z-standardize numeric, continuous variables

Description

This function z-standardizes the specified numeric columns or all numeric columns if none are specified. A z-standardized scale centers at a mean of 0.0 and has a standard deviation of 1.0, making it comparable to other z-standardized distributions.

Usage

z_scale(data, ..., name = NULL, overwrite = FALSE)

Arguments

data

A tibble or a tdcmm model.

...

Numeric variables to be z-standardized. If none are provided, all numeric columns will be z-standardized.

name

Optional name for the new z-standardized variable when a single variable is provided. By default, the name will be the original variable name suffixed with ⁠_z⁠.

overwrite

Logical. If TRUE, it overwrites the original variable(s) with the z-standardized values. If FALSE (default), a new variable(s) is created.

Value

A tdcmm model with the z-standardized variable(s).

See Also

Other scaling: categorize_scale(), center_scale(), dummify_scale(), minmax_scale(), recode_cat_scale(), reverse_scale(), setna_scale()

Examples

WoJ %>% z_scale(autonomy_emphasis)
WoJ %>% z_scale(autonomy_emphasis, name = "my_zstdized_variable")
WoJ %>%
  z_scale(autonomy_emphasis) %>%
  tab_frequencies(autonomy_emphasis, autonomy_emphasis_z)

joon-e/tidycomm documentation built on Feb. 24, 2024, 8:58 a.m.