group | R Documentation |
Array objects (e.g. FLQuant or FLQuants) are divided along a single dimnension following a given index or expression, an aggregating function is applied to each subset, and the results are joined again. Data can be added, for example, by decade or for two age groups.
group(x, FUN, ...)
## S4 method for signature 'FLQuant,function'
group(x, FUN = sum, ...)
x |
An object to group. |
FUN |
A function to apply along the chosen dimension, defaults to 'sum'. |
... |
An expression or indexing vector, named as the chosen dimension. Extra arguments to FUN can also be provided, but cannmot match names in x. |
A single object with reduced dimensionality.
Iago Mosqueira (WMR)
data(ple4)
# Add catch-at-age along two age groups, 'juv'eniles and 'adu'lts
group(catch.n(ple4), sum, age=c('juv', 'juv', rep('adu', 8)))
# An expression can use based on dimnames
group(catch.n(ple4), sum, age=age < 3)
# Mean by lustrum, by using 'year - year %% 5'
group(catch.n(ple4), mean, year = year - year %% 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.