col_to_binaries {saros}R Documentation

Mutate a (factor, character, integer, etc) column into multiple columns,

Description

Easily mutate a single column into multiple columns (~dummies+1), while retaining variable labels and order of the original factor variable.

Usage

col_to_binaries(data, col, var_separator = "___", label_separator = " - ")

Arguments

data

Survey data

⁠obj:<data.frame>|obj:<tbl_df>⁠ // Required

A data frame (or a srvyr-object) with the columns specified in the chapter_overview 'dep_cat', etc columns.

col

Single column. Tidy-select.

var_separator

Variable separator

⁠scalar<character>⁠ // default: NULL (optional)

Separator between old variable name and categories.

label_separator

⁠scalar<character>⁠ // default: NULL (optional)

Separator between old label name and new label part.

Value

Original data frame with the binary columns attached, containing new labels.

Examples

col_to_binaries(ex_survey, col = b_3, label_separator = "  -  ")

[Package saros version 1.0.4 Index]