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": The name of the category, must be unique within a set of categories

  • "id": An integer that uniquely identifies the category

  • "numeric_value": A numeric value associated with the category (defaults to NA meaning that no value is associated, not that the category is missing)

  • "missing": Logical indicating whether the category should be considered missing (defaults to FALSE)

  • "selected": Logical indicating whether the category is selected or not (defaults to FALSE)

  • "date": A string indicating a day or range of days that should be associated with the category. Accepted formats are "YYYY-MM-DD" ("2020-01-01") for a day, "YYYY-WXX" ("2020-W01") for an ISO week (a week that starts on a Monday, with the first week of the year being the first week with more than 4 days in it), "YYYY-MM" ("2020-01") for a month, "YYYY" ("2020") for a year, or "YYYY-MM-DD,YYYY-MM-DD" ("2020-01-01,2020-01-10") for a range of days.

Categories(..., data = NULL)

Category(..., data = NULL)

Arguments

...

Category attributes

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.

Examples

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)
#> [1] TRUE
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)
#> [1] TRUE