View source: R/trans_categ_mapping.R
| categ_mapping | R Documentation |
Convert a factor column into dummy variables (one‑hot encoding) using model.matrix without intercept.
Each level becomes a separate binary column.
categ_mapping(attribute)
attribute |
attribute to be categorized. |
This is a light wrapper around stats::model.matrix(~ attr - 1, data) that drops the original column
and returns only the dummy variables.
returns a data frame with binary attributes, one for each possible category.
cm <- categ_mapping("Species")
iris_cm <- transform(cm, iris)
# can be made in a single column
species <- iris[,"Species", drop=FALSE]
iris_cm <- transform(cm, species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.