Multiple Response variables are Categorical Arrays in which one or more categories are set as "selected". These methods allow you to view and set that attribute.

is.dichotomized(x)

dichotomize(x, i)

undichotomize(x)

is.selected(x)

is.selected(x) <- value

# S4 method for class 'Categories'
is.dichotomized(x)

# S4 method for class 'Categories,numeric'
dichotomize(x, i)

# S4 method for class 'Categories,logical'
dichotomize(x, i)

# S4 method for class 'Categories,character'
dichotomize(x, i)

# S4 method for class 'Categories'
undichotomize(x)

# S4 method for class 'CategoricalVariable,ANY'
dichotomize(x, i)

# S4 method for class 'CategoricalArrayVariable,ANY'
dichotomize(x, i)

# S4 method for class 'CategoricalVariable'
undichotomize(x)

# S4 method for class 'CategoricalArrayVariable'
undichotomize(x)

# S4 method for class 'Categories'
is.selected(x)

# S4 method for class 'Categories'
is.selected(x) <- value

# S4 method for class 'Category'
is.selected(x)

# S4 method for class 'Category'
is.selected(x) <- value

Arguments

x

Categories or a Variable subclass that has Categories

i

For the dichotomize methods, the numeric or logical indices of the categories to mark as "selected", or if character, the Category "names". Note that unlike some other categorical variable methods, numeric indices are positional, not with reference to category ids.

value

For is.selected<-, A logical vector indicating whether the category should be selected. For a single category the value should be either TRUE or FALSE. To change the selection status for a Categories object, supply a logical vector which is the same length as the number of categories.

Value

Categories or the Variable, (un)dichotomized accordingly

Details

dichotomize lets you specify which categories are "selected", while undichotomize strips that selection information. Dichotomize converts a Categorical Array to a Multiple Response, and undichotomize does the reverse. is.dichotomized reports whether categories have any selected values.

is.selected is lower level and maps more directly onto the "selected" attributes of categories. The best illustration of this difference is that is.selected(categories(var)) returns a logical vector, a value for each category, while is.dichotomized(categories(var)) returns a single TRUE/FALSE value.

See also

Examples

if (FALSE) { # \dontrun{
ds <- newExampleDataset()
is.MR(ds$allpets)
is.dichotomized(categories(ds$allpets))
is.selected(categories(ds$allpets))
ds$allpets <- undichotomize(ds$allpets)
is.CA(ds$allpets)
ds$allpets <- dichotomize(ds$allpets, "selected")
is.MR(ds$allpets)
} # }