CategoricalVariable: CategoricalVariable Class

CategoricalVariableR Documentation

CategoricalVariable Class

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 queue_extend()

extend the variable with new values

Usage
CategoricalVariable$queue_extend(values)
Arguments
values

to add to the variable


Method queue_shrink()

shrink the variable

Usage
CategoricalVariable$queue_shrink(index)
Arguments
index

a bitset or vector representing the individuals to remove


Method size()

get the size of the variable

Usage
CategoricalVariable$size()

Method .update()

Usage
CategoricalVariable$.update()

Method .resize()

Usage
CategoricalVariable$.resize()

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 July 15, 2022, 5:06 p.m.