Description Usage Arguments Details Value NOTE Examples
View source: R/multipleChoiceExpand.R
Function to recode a choose-multiple column where multiple answers are recorded in the same element (e.g. "ab ac ad", "ef eg eh") to a data frame with multiple separate 0/1 columns e.g.:
1 2 | expandMultChoice(answers, choices = NULL, naCode = NULL,
naQuestion = NULL)
|
answers |
Character vector with given answers (strings containing the choices) |
choices |
(optional) Character vector with choices to be used (each will
become a column). If not supplied, choices will be determined from the
|
naCode |
(optional) Single element specifying what character code
equates to |
naQuestion |
(optional) TRUE/FALSE vector of the same length as answers;
in rows where this is false, all columns will be coded as |
ab ac ad ef eg eh [1,] 1 1 1 0 0 0 [2,] 0 0 0 1 1 1
a data frame with multiple separate 0/1 columns
naCode
must exist as the only answer in a column (an answer that
contains both a valid answer and the NA
code will not be recognized as
NA
- instead, the NA
code will be output as an extra answer
column (if choices
parameter is not given))
1 2 3 | # Expand responses in variable w7 of sampleData2
sampleData2 <- renameODK(sampleData2)
temp <- expandMultChoice(sampleData2$ws7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.