This function counts the number of occurrences per row in a number of categorical / single-code variables.

superspread_count(df, select_helpers = everything())

Arguments

df

Data frame to apply function to.

select_helpers

Use dplyr select helpers to apply function only to required columns. Leave blank to include everything

Value

n number of new binary / multiple-choice columns / variables, with values representing the count of row-occurrences in the original set of input categorical/single-code variables. n represents the number of unique values found in the input variables.

See also

Other superspread functions: superspread()

Examples

if (FALSE) { # \dontrun{
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_count(df = dt, select_helpers = contains("cat"))
} # }