Unite Checkbox Variables in REDCap
combine_redcap_checkboxes.RdWhile useful for data collection, checkbox variables may need to be merged/united into a singular variable for analysis. REDCap internally labels checkbox variables are "prefix___1", with the number matchin the number response in the checkbox variable. Warning: if REDCap ever changes this format, this function will stop working.
Arguments
- df
Data.frame or tibble.
- prefix
Character, prefix of checkbox variable to be combined. If left blank or unspecified, all checkbox variables will be impacted.
- sep
Character, delimiter to separate multiple values.
- drop_cols
Logical, option to drop united columns after transformation. Default set to FALSE.