minmax_scale {tidycomm} | R Documentation |
Rescale numeric continuous variables to new minimum/maximum boundaries
Description
Given a specified minimum and maximum, this function translates each value into a new value within this specified range. The transformation maintains the relative distances between values, resulting in changes to the mean and standard deviations. However, if both the original scale and the transformed scale are z-standardized, they will be equal again, indicating that the relative positions and distributions of the values remain consistent.
Usage
minmax_scale(
data,
...,
change_to_min = 0,
change_to_max = 1,
name = NULL,
overwrite = FALSE
)
Arguments
data |
|
... |
Numeric variables to be min-max scaled. If none are provided, all numeric columns will be scaled. |
change_to_min |
The desired minimum value after scaling. |
change_to_max |
The desired maximum value after scaling. |
name |
Optional name for the new scaled variable when a single variable is provided. By default, the name will be the original variable name suffixed with the range. For example, "variable" becomes "variable_3to5". Negative values are prefixed with "neg" to avoid invalid columns names (e.g., -3 to 3 becomes "variable_neg3to5"). |
overwrite |
Logical. If |
Value
A tdcmm model with the min-max scaled variable(s).
See Also
Other scaling:
categorize_scale()
,
center_scale()
,
dummify_scale()
,
recode_cat_scale()
,
reverse_scale()
,
setna_scale()
,
z_scale()
Examples
WoJ %>% minmax_scale(autonomy_emphasis, change_to_min = 0,
change_to_max = 1)
WoJ %>% minmax_scale(autonomy_emphasis, name = "my_scaled_variable",
change_to_min = 0, change_to_max = 1)
WoJ %>%
minmax_scale(autonomy_emphasis, change_to_min = 0, change_to_max = 1) %>%
tab_frequencies(autonomy_emphasis, autonomy_emphasis_0to1)