CategoricalVariable: CategoricalVariable Class

Description Methods

Description

Represents a categorical variable for an individual. This class should be used for discrete variables taking values in a finite set, such as infection, health, or behavioral state. It should be used in preference to IntegerVariable if possible because certain operations will be faster.

Methods

Public methods


Method new()

Create a new CategoricalVariable

Usage
CategoricalVariable$new(categories, initial_values)
Arguments
categories

a character vector of possible values

initial_values

a character vector of the initial value for each individual


Method get_index_of()

return a Bitset for individuals with the given values

Usage
CategoricalVariable$get_index_of(values)
Arguments
values

the values to filter


Method get_size_of()

return the number of individuals with the given values

Usage
CategoricalVariable$get_size_of(values)
Arguments
values

the values to filter


Method get_categories()

return a character vector of possible values. Note that the order of the returned vector may not be the same order that was given when the variable was intitialized, due to the underlying unordered storage type.

Usage
CategoricalVariable$get_categories()

Method queue_update()

queue an update for this variable

Usage
CategoricalVariable$queue_update(value, index)
Arguments
value

the new value

index

the indices of individuals whose value will be updated to the one specified in value. This may be either a vector of integers or a Bitset.


Method .update()

Usage
CategoricalVariable$.update()

Method clone()

The objects of this class are cloneable with this method.

Usage
CategoricalVariable$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


individual documentation built on Oct. 25, 2021, 9:09 a.m.