Convert a categorical Action column to one-hot (binary indicator) columns.
Usage
action_to_onehot(
data,
action_col = "Action",
states = NULL,
drop_action = TRUE,
sort_states = FALSE,
prefix = ""
)Arguments
- data
Data frame containing an action column.
- action_col
Character. Name of the action column. Default: "Action".
- states
Character vector or NULL. States to include as columns. If NULL, uses all unique values. Default: NULL.
- drop_action
Logical. Remove the original action column. Default: TRUE.
- sort_states
Logical. Sort state columns alphabetically. Default: FALSE.
- prefix
Character. Prefix for state column names. Default: "".