Description Generic function Methods Author(s) See Also Examples
Operators acting on FLQuant, FLCohort, FLPar, FLComp, and derived classes to extract or replace sections of an object.
Please note the difference between referencing sections of an object by position, using
values of class numeric
, or by dimnames, of class character
. See examples
below.
All classes that are derived from FLComp
(for example, FLStock
and
FLBiol
) can be subset along the six dimensions of their FLQuant
slots.
Classes that are derived from FLlst
(for example, FLStocks
and
FLBiols
) can be subset in a similar way to ordinary list objects.
An FLFleet object has three levels (fleet, metier and catch). The [
and
[[
operators can be used to access the different levels of an FLFleet
object (i.e FLMetier
and FLCatch
objects).
Using the single [
operator returns an object of the same type but with only a
subset of the metier and catch objects that were in the original object. For example,
using [
on an FLFleet
object returns an FLFleet
object, but with
only a selected subset of FLMetier
and FLCatch
objects. Using [
on an FLMetier
object returns an FLMetier
object, but with only a
selected subset of FLCatch
objects.
More than one metier or catch may be specified. However, if multiple catches are
specified it must be possible to extract all of them from the metiers that are
specified. For example, fleet[1:2,1:2] will extract both the first and second
FLCatch
objects from the first and second FLMetier
objects. If either of
the two metiers has only a single catch an error will be returned.
Using the double [[
operators on an FLFleet
or FLMetier
object
returns an object of the next level down. For example, using [[
on an
FLMetier
returns an FLCatch
object. The [[
operators can be
combined to extract a single FLCatch
from an FLFleet
object (see below).
Objects of class FLIndex
might have a combination of FLQuant
of various lengths along the first dimension. When extracting from an FLIndex
object, indices for the first dimension are ignored for those slots whose first
dimensions is of length=1.
[x,i,j,drop]
[<-(x,i,j,value)
[[<-(x,i,j,value)
\$<-(x,name,value)
Returns an FLQuant
object, subset along any of the six dimensions (quant, year, unit, season, area and iter).
Returns a subset of an FLlst
object as an FLlst
object. This also applies to classes derived from FLlst
including FLStocks
and FLFleets
. It behaves in a similar way to the list operator [
Subset an FLPar
object.
Returns an FLStock
where all the FLQuant
slots have been subset by quant, year, unit, season, area and iter.
Returns an FLCatch
where all the FLQuant
slots have been subset by quant, year, unit, season, area and iter.
Returns an FLBiol
where all the FLQuant
slots have been subset by quant, year, unit, season, area and iter.
Describe method
Returns an FLFleet
object that contains only the i FLMetier
s and the j FLCatch
es of the FLFleet
object. i and j are vectors (numerics or characters) that describe the position of the objects in the FLMetiers
or FLCatches
lists. This enables mutiple FLMetier
s and FLCatch
es to be extracted.
Returns an FLFleet
object that contains only the i FLMetier
s of the FLFleet
object. i is a vector (numeric or character) that describes the position of the FLMetier
in the FLMetiers
lists.
Returns an FLMetier
that contains the i FLCatch
es of the FLMetier
. i is a vector (numeric or character) that describes the position of the FLCatch
es in the FLCatches
list.
Returns the specified element of the list. For example, for an FLStocks
object, stocks[[1]] will return a single FLStock
.
Returns the ith FLMetier
of the FLFleet
. i can be a numeric describing the position of the FLMetier
in the FLMetiers
list, or a character string of the catch names.
Returns the ith FLCatch
of the FLMetier
. i can be a numeric describing the position of the FLCatch
in the FLCatches
list, or a character string of the catch names. This can be used with the FLFleet
accessor above to extract a single FLCatch
from an FLFleet
object.
Describe method
The FLR Team
Extract
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | flq <- FLQuant(rnorm(50), dimnames=list(age=1:5, year=1990:2000, season=1:4))
flq[1,]
flq[,1:5]
flq[,'1990']
flq[1:2,,,c(1,3)]
# load a fleet
data(bt4)
# extract the first metier
met <- bt4[[1]]
# extract the first catch of that metier
catch <- met[[1]]
# do it all once to get the catch
catch <- bt4[[1]][[1]]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.