center_scale: Center numeric, continuous variables

center_scaleR Documentation

Center numeric, continuous variables

Description

This function centers the specified numeric columns or all numeric columns if none are specified. A centered scale has a mean of 0.0.

Usage

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

Arguments

data

A tibble or a tdcmm model.

...

Numeric variables to be centered. If none are provided, all numeric columns will be centered.

name

Optional name for the new centered variable when a single variable is provided. By default, the name will be the original variable name suffixed with ⁠_centered⁠.

overwrite

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

Value

A tdcmm model with the centered variable(s).

See Also

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

Examples

WoJ %>% dplyr::select(autonomy_emphasis) %>% center_scale(autonomy_emphasis)
WoJ %>% center_scale(autonomy_emphasis, name = "my_centered_variable")
WoJ %>% center_scale(overwrite = TRUE)
WoJ %>%
  center_scale(autonomy_emphasis) %>%
  tab_frequencies(autonomy_emphasis, autonomy_emphasis_centered)

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