View source: R/model-design-tools.R
enw_one_hot_encode_feature | R Documentation |
This function takes a data.frame and a categorical variable, performs one-hot encoding, and column-binds the encoded variables back to the data.frame.
enw_one_hot_encode_feature(metaobs, feature, contrasts = FALSE)
metaobs |
A data.frame containing the data to be encoded. |
feature |
The name of the categorical variable to one-hot encode as a character string. |
contrasts |
Logical. If TRUE, create one-hot encoded variables with contrasts; if FALSE, create them without contrasts. Defaults to FALSE. |
Functions used to formulate models
enw_add_cumulative_membership()
,
enw_add_pooling_effect()
,
enw_design()
,
enw_effects_metadata()
metaobs <- data.frame(week = 1:2)
enw_one_hot_encode_feature(metaobs, "week")
enw_one_hot_encode_feature(metaobs, "week", contrasts = TRUE)
metaobs <- data.frame(week = 1:6)
enw_one_hot_encode_feature(metaobs, "week")
enw_one_hot_encode_feature(metaobs, "week", contrasts = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.