Learn R Programming

crunch (version 1.9.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)

## S3 method for class 'Categories,ANY,ANY': [(x, i, j, ..., drop = TRUE)

## S3 method for class 'Categories,numeric,ANY': [(x, i, j, ..., drop = TRUE)

## S3 method for class 'Categories,ANY,ANY,ANY': [(x, i, j, ...) <- value

## S3 method for class 'Categories': names(x)

## S3 method for class 'Categories': values(x)

## S3 method for class 'Categories': ids(x)

## S3 method for class 'Categories': names(x) <- value

## S3 method for class 'Categories': values(x) <- value

## S3 method for class 'Categories': 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
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