dummify_scale {tidycomm} | R Documentation |
Convert categorical variables to dummy variables
Description
This function transforms specified categorical variables into dummy variables. Each level of the categorical variable is represented by a new dummy variable. Missing values are retained. These new dummy variables are appended to the original data frame. This function does not allow specifying new column names for the dummy variables. Instead, it follows a consistent naming pattern: the new dummy variables are named using the original variable name with the category value appended. For example, if a categorical variable named "autonomy" with levels "low", "medium", "high" is dummified, the new dummy variables will be named "autonomy_low", "autonomy_medium", "autonomy_high".
Usage
dummify_scale(data, ..., overwrite = FALSE)
Arguments
data |
|
... |
Categorical variables to be transformed into dummy variables. Category names will be automatically appended to the newly created dummy variables. |
overwrite |
Logical. If |
Value
A tdcmm model with the dummy variables appended.
See Also
Other scaling:
categorize_scale()
,
center_scale()
,
minmax_scale()
,
recode_cat_scale()
,
reverse_scale()
,
setna_scale()
,
z_scale()
Examples
WoJ %>% dplyr::select(temp_contract) %>% dummify_scale(temp_contract)
WoJ %>% categorize_scale(autonomy_emphasis, breaks = c(2, 3),
labels = c('low', 'medium', 'high')) %>%
dummify_scale(autonomy_emphasis_cat) %>% dplyr::select(starts_with('autonomy_emphasis'))