crunch (version 1.27.7)

dichotomize: Indicate how categories represent a dichotomized value

Description

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.

Usage

is.dichotomized(x)

dichotomize(x, i)

undichotomize(x)

is.selected(x)

is.selected(x) <- value

# S4 method for Categories is.dichotomized(x)

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

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

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

# S4 method for Categories undichotomize(x)

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

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

# S4 method for CategoricalVariable undichotomize(x)

# S4 method for CategoricalArrayVariable undichotomize(x)

# S4 method for Categories is.selected(x)

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

# S4 method for Category is.selected(x)

# S4 method for 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

describe-entity

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataCamp Workspace