Function to expand response to a more than one answer multiple choice question coded as a concatenated string
Source:R/expand_choice.R
expand_choice.Rd
Function to expand response to a more than one answer multiple choice question coded as a concatenated string
Arguments
- df
A dataframe containing the vector data that requires expansion.
- x
Name of variable in
df
containing vector needing expansion.- values
Vector of string values used to create concatenated string response.
- pattern
Pattern used to separate values in the concatenated string. Default is "" for concatenated strings with no separator.
- prefix
Prefix to names of newly created variables.
- labels
Vector of names to use for columns of resulting data.frame. If not specified, columns are named using
values
.- sep
Charater to separate
prefix
fromlabels
in the names of newly created variables.
Value
A data.frame with same rows as df
containing columns
corresponding to each newly created variable.
Examples
if (FALSE) { # \dontrun{
expandMultipleChoice(df = individual,
x = "mddw1",
values = as.character(0:18),
pattern = " ",
prefix = "mddw",
sep = "")
} # }