collapse_dems: Collapse demographic variables across *n* years

Description Usage Arguments Value

View source: R/collapse_dems.R

Description

This function will collapse demographic variables across years into a single vector. If demographics vary across years, it will return the most common value (i.e., majority rule). If there is a tie, it will randomly select from the tied demographic values. If there are missing data across any of the years, the value from the observed years will be retained. In other words, the function can be helpful for collapsing demographic data even when no demographic values vary.

Usage

1
collapse_dems(d, pat, seed = 100, print = TRUE)

Arguments

d

Data frame which includes the variables to be collapsed

pat

Common string pattern represented in all variables to be collapsed.

seed

Seed to set for reproducibility. Defaults to 100.

print

Logical. Should the number of students who were assigned based on a majority rule and the number of students who were randomly assigned be printed to the console? Defaults to TRUE.

Value

Factor vector of demographic data with the properties described above. The number of


datalorax/sundry documentation built on April 11, 2021, 1:50 p.m.