Learn R Programming

crunch (version 1.14.4)

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 themselves subclass list and contain the following fields: "name", "id", "numeric_value", "missing", and optionally "selected".

Usage

Categories(..., data = NULL)
Category(..., data = NULL)
"["(x, i, j, ..., drop = TRUE)
"["(x, i, j, ..., drop = TRUE)
"["(x, i, j, ...) <- value
"names"(x)
"values"(x)
"ids"(x)
"names"(x) <- value
"values"(x) <- value
"ids"(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
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