superspread: Creates dummy variables from multiple categorical variables....

superspreadR Documentation

Creates dummy variables from multiple categorical variables. Uses data.table() for speed (enhanced from the previous version) Uses dplyr select() special functions to select categorical variables.

Description

Creates dummy variables from multiple categorical variables. Uses data.table() for speed (enhanced from the previous version) Uses dplyr select() special functions to select categorical variables.

Usage

superspread(df, select_helpers)

Arguments

df

Data frame containing the multiple categorical variables.

select_helpers

Uses dplyr-style select functions to select multiple variables. Use everything() to select all variables. These variables must all be character type.

See Also

Other superspread functions: superspread_count()

Examples

superspread(iris,"Species")
## Not run: 
library(data.table)
library(dplyr)
dt <- data.table(id = 1:10000,
                 cat1 = sample(letters[1:3],10000,replace = TRUE),
                 cat2 = sample(letters[1:4],10000,replace = TRUE),
                 cat3 = sample(letters[1:5],10000,replace = TRUE))
dt <- as.data.table(dt)
superspread(df = dt, select_helpers = contains("cat"))

## End(Not run)


martinctc/surveytools documentation built on Nov. 21, 2024, 10:48 p.m.