population | R Documentation |
The 'population' R6 class regroups different individuals profiles. It serves as a wrapper for simultaneous interactions with multiple individual profiiles. The object is used for population description and generation procedures.
profiles
A list of individual profile.
n
A list of individuals' numbers per profile (repecting the profiles' order).
new()
Create a new 'population' object. The function allows to create an object populated with individual profiles.
population$new(profiles = list(NULL), n = list(NULL))
profiles
A list of individual profiles for population.
n
The associated numbers for each profile to appear in the dataset.
add_profile()
Add new individual profile and respective desired number of individuals.
population$add_profile(individual, n, profile_name = NULL)
individual
Individual profile to be added
n
A number associate to the added profile
profile_name
An added profile name, not required. Is NULL by default.
get_chars()
Get a vector of available characteristics' names across all individual profiles in population.
population$get_chars()
Character vector with unique characteristics names within populatoin.
get_n()
Get a vector regroupping individuals' numbers per profile
population$get_n()
Numeric vector with numbers of n by individual profile.
get_rules()
Extract 'decision_rule' objects across individual profiles
population$get_rules()
A list of rules present within population.
clone()
The objects of this class are cloneable with this method.
population$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Create individuals ind1 <- individual$new() ind1$add_characteristics(Age = rnorm(mean = 40, sd = 10)) ind1$add_decision_rule(drule <- decision_rule$new()) ind2 <- individual$new() ind2$add_characteristics(Age = rnorm(mean = 30, sd = 5)) ind2$add_decision_rule(drule <- decision_rule$new()) # Regroup individuals into population pop <- population$new(profiles = list(ind1, ind2), n = list(10, 15)) # Add new profile ind3 <- individual$new() ind3$add_characteristics(Age = rnorm(mean = 50, sd = 4), Salary = runif(min = 1, max = 5)) ind3$add_decision_rule(drule <- decision_rule$new()) pop$add_profile(ind3, 5) pop$get_chars() pop$get_n() pop$get_rules()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.