trim | R Documentation |
Trim FLR objects using named dimensions
trim(x, ...)
## S4 method for signature 'FLArray'
trim(x, ...)
## S4 method for signature 'FLComp'
trim(x, ...)
## S4 method for signature 'FLS'
trim(x, ...)
## S4 method for signature 'FLBiol'
trim(x, ...)
Subsetting of FLR objects can be carried out with dimension names by using
trim
. A number of dimension names and selected dimensions are passed
to the method and those are used to subset the input object.
Exceptions are made for those classes where certain slots might differ in
one or more dimensions. If trim is applied to an FLQuant object of length 1
in its first dimension and with dimension name equal to 'all', values to
trim
specified for that dimension will be ignored. For example,
FLStock
objects contain slots with length=1 in their first
dimension. Specifying values to trim over the first dimension will have no
effect on those slots (catch
, landings
, discards
, and
stock
). Calculations might need to be carried out to recalculate
those slots (e.g. using computeCatch
, computeLandings
,
computeDiscards
and computeStock
) if their quant-structured
counterparts are modified along the first dimension.
trim(x)
The FLR Team
FLQuant, FLStock, FLCohort, FLIndex
flq <- FLQuant(rnorm(90), dimnames=list(age=1:10, year=2000:2016))
trim(flq, year=2000:2005)
# which is equivalent to
window(flq, start=2000, end=2005)
trim(flq, year=2000:2005, age=1:2)
# Now on an FLStock
data(ple4)
summary(trim(ple4, year=1990:1995))
# If 'age' is trimmed in ple4, catch, landings and discards need to be
# recalculated
shpl4 <- trim(ple4, age=1:4)
landings(shpl4) <- computeLandings(shpl4)
discards(shpl4) <- computeDiscards(shpl4)
catch(shpl4) <- computeCatch(shpl4)
summary(shpl4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.