CategoricalVariable | R Documentation |
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.
new()
Create a new CategoricalVariable
CategoricalVariable$new(categories, initial_values)
categories
a character vector of possible values
initial_values
a character vector of the initial value for each individual
get_index_of()
return a Bitset
for individuals with the given values
CategoricalVariable$get_index_of(values)
values
the values to filter
get_size_of()
return the number of individuals with the given values
CategoricalVariable$get_size_of(values)
values
the values to filter
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.
CategoricalVariable$get_categories()
queue_update()
queue an update for this variable
CategoricalVariable$queue_update(value, index)
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
.
queue_extend()
extend the variable with new values
CategoricalVariable$queue_extend(values)
values
to add to the variable
queue_shrink()
shrink the variable
CategoricalVariable$queue_shrink(index)
index
a bitset or vector representing the individuals to remove
size()
get the size of the variable
CategoricalVariable$size()
.update()
CategoricalVariable$.update()
.resize()
CategoricalVariable$.resize()
clone()
The objects of this class are cloneable with this method.
CategoricalVariable$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.