collapse01 | R Documentation |
Collapse a group of binary variables (e.g. those generated by checkbox variables in REDCap) into summary columns.
collapse01(
df,
cols,
prefix = NULL,
suffix = NULL,
output = c("list", "yesno", "n"),
remove = TRUE,
binary0 = c(0, "0", "No", "no"),
binary1 = c(1, "1", "Yes", "yes")
)
df |
Dataframe. |
cols |
List of columnn names of binary variables desired to be collapsed. |
prefix |
String to add to the start of all summary columns names. |
suffix |
String to add to the end of all summary columns names. |
output |
List of desired outputs: yesno (any values selected), n (number of values selected) and list (list of column names of all values selected). |
remove |
Logical value to remove columns supplied to the "cols" parameter |
binary0 |
List of all values corresponding to "0" (No) in the binary variable (default = 0 or no) |
binary1 |
List of all values corresponding to "1" (Yes) in the binary variable (default = 1 or yes). |
Dataframe with up to 3 additional columns: yesno (any values selected), n (number of values selected) and list (list of column names of all values selected).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.