stock_tag {gadget3} | R Documentation |
Gadget3 tag dimension
Description
Add tag dimensions to g3_stock classes
Usage
g3s_tag(inner_stock, tag_ids, force_untagged = TRUE)
Arguments
inner_stock |
A |
tag_ids |
A vector of numeric tags the stock can have, generated by |
force_untagged |
If TRUE, if "untagged" tag 0 isn't present it will be added. |
Value
g3s_tag
A g3_stock
with an additional 'tag' dimension.
When iterating over the stock, iterate over each tag in turn, tag will be set to the current integer area.
When interacting with another stock, iterate over each tag in turn, the variable name will depend on the scenario, e.g. prey_tag.
Examples
# Make a lookup of text names to integers
tags <- c('H1-00', 'H1-01')
tags <- structure(seq_along(tags), names = tags)
# prey_a can have any of these tags
prey_a <- g3_stock('prey_a', seq(1, 10)) %>% g3s_tag(tags)
# Use stock_instance to see what the array would look like
g3_stock_instance(prey_a)
[Package gadget3 version 0.12-1 Index]