stock_age {gadget3} | R Documentation |
Gadget3 stock age dimensions
Description
Add age dimensions to g3_stock classes
Usage
g3s_age(inner_stock, minage, maxage)
g3s_agegroup(inner_stock, agegroups)
Arguments
inner_stock |
A |
minage |
Minimum age to store, integer. |
maxage |
Maximum age to store, integer. |
agegroups |
(optionally named) list of vectors of ages, grouping them together. |
Value
g3s_age
A g3_stock
with an additional 'age' dimension.
When iterating over the stock, iterate over each age in turn, age will be set to the current integer age.
When intersecting with another stock, only do anything if age is betweem minage and maxage.
If an age dimension already exists, it is redefined with new parameters.
g3s_agegroup
A g3_stock
with an additional 'age' dimension.
When iterating over the stock, iterate over each agegroup in turn, age will be set to the first age in the group.
When intersecting with another stock, only do anything if age is part of one of the groups.
Examples
# Define a stock with 3 lengthgroups and 3 ages
stock <- g3_stock('name', c(1, 10, 100)) %>%
g3s_age(5, 10)
# Use stock_instance to see what the array would look like
g3_stock_instance(stock)
# Define a stock that groups age into "young" and "old"
stock <- g3_stock('name', c(1, 10, 100)) %>%
g3s_agegroup(list(
young = 5:7,
old = 8:10))
# Use stock_instance to see what the array would look like
g3_stock_instance(stock)