Learn R Programming

crunch (version 1.24.0)

Categories-class: Categories in CategoricalVariables

Description

CategoricalVariables, as well as the array types composed from Categoricals, contain Categories. Categories are a subclass of list that contains only Category objects. Category objects are themselves subclasses of lists and contain the following fields: "name", "id", "numeric_value", "missing", and optionally "selected".

Usage

Categories(..., data = NULL)

Category(..., data = NULL)

# S4 method for AbstractCategories,ANY,ANY [(x, i, j, ..., drop = TRUE)

# S4 method for AbstractCategories,character,ANY [(x, i, j, ..., drop = TRUE)

# S4 method for AbstractCategories,numeric,ANY [(x, i, j, ..., drop = TRUE)

# S4 method for AbstractCategories,character,ANY,ANY [(x, i, j, ...) <- value

# S4 method for AbstractCategories,character [[(x, i, j, ...)

# S4 method for AbstractCategories,character,ANY,ANY [[(x, i, j, ...) <- value

# S4 method for AbstractCategories names(x)

# S4 method for AbstractCategories names(x) <- value

# S4 method for AbstractCategories ids(x)

# S4 method for Categories,ANY,ANY,ANY [(x, i, j, ...) <- value

# S4 method for Categories ids(x) <- value

# S4 method for Categories values(x)

# S4 method for Categories values(x) <- value

Arguments

...

additional arguments to [, ignored

data

For the constructor functions Category and Categories, you can either pass in attributes via ... or you can create the objects with a fully defined list representation of the objects via the data argument. See the examples.

x

For the attribute getters and setters, an object of class Category or Categories

i

For the [ methods, just as with list extract methods

j

Invalid argument to [, but in the generic's signature

drop

Invalid argument to [, but in the generic's signature

value

For [<-, the replacement Category to insert

Examples

Run this code
# NOT RUN {
cat.a <- Category(name="First", id=1, numeric_value=1, missing=FALSE)
cat.b <- Category(data=list(name="First", id=1, numeric_value=1, missing=FALSE))
identical(cat.a, cat.b)
cat.c <- Category(name="Second", id=2)
cats.1 <- Categories(cat.a, cat.c)
cats.2 <- Categories(data=list(cat.a, cat.c))
identical(cats.1, cats.2)
# }

Run the code above in your browser using DataLab