View source: R/standarize_variable.R
standardize_variable | R Documentation |
standardize_variable()
standardizes the selected columns in a
data.frame using base::scale()
. By default, this function
overwrites the column to be scaled. Use the suffix
argument to avoid this
behavior.
standardize_variable()
and standardise_variable()
are synonyms.
standardize_variable(data, cols = dplyr::everything(), suffix = NULL) standardise_variable(data, cols = dplyr::everything(), suffix = NULL)
data |
A data frame containing the variables to standardize. |
cols |
< |
suffix |
A character suffix to be added to the scaled variables names.
When suffix is set to |
A data frame with the standardized columns.
standardize_variable
and grouped_df
Note that standardize_variable
ignores grouping. Meaning that if you
call this function on a grouped data frame (see dplyr::grouped_df), the
overall variables' mean and standard deviation will be used for the
standardization.
ho_et_al %>% standardize_variable(sdo) ho_et_al %>% standardize_variable(c(sdo, linkedfate), suffix = "scaled")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.