Description Usage Arguments Value Author(s) Examples
A multiple reponse variable is one whose values consist of a list of possible choices. Such a variable can be represented in a linear model through a matrix of indicator variables.
1 | multresp(x, split = "[ \t,]+", sep = ".", root = deparse(substitute(x)))
|
x |
a factor or character vector containing comma- or blank-separated lists of reponse choices for each subject. For example, each subject could have a list of symptoms: c('cough fever', 'cough bronchitis', 'headache wheeze', ”, 'cough high_fever', NA). |
split |
a regular expression matching the separator between fields. The default is |
sep |
the separator used to generated the column names of the indicator matrix. |
root |
the root for column names. By default, the name of the variable. the |
A matrix of indicator variables. For, example, if
x <-c('cough fever', 'cough bronchitis', 'headache wheeze', '', 'cough high_fever', NA)
multresp(x)
produces:
x.bronchitis x.cough x.fever x.headache x.high_fever x.wheeze
[1,] 0 1 1 0 0 0
[2,] 1 1 0 0 0 0
[3,] 0 0 0 1 0 1
[4,] 0 0 0 0 0 0
[5,] 0 1 0 0 1 0
[6,] 0 0 0 0 0 0
G. Monette (georges@yorku.ca)
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.