Extract {FLCore} | R Documentation

## Extract or Replace Parts of an FLR Object

### Description

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-class` 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.

### Generic function

  [x,i,j,drop]
  [<-(x,i,j,value)
  [[<-(x,i,j,value)
  $<-(x,name,value)

### Methods

signature(x=FLQuant,i=ANY,j=ANY,drop=missing) :
  Returns an `FLQuant` object, subset along any of the six dimensions (quant, year, unit, season, area and iter).
signature(x=FLlst,i=ANY,j=missing,drop=missing) :
  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 `[`
signature(x=FLPar,i=ANY,j=ANY,drop=missing) :
  Subset an `FLPar` object.
signature(x=FLStock,i=ANY,j=ANY,drop=missing) :
  Returns an `FLStock` where all the `FLQuant` slots have been subset by quant, year, unit, season, area and iter.
signature(x=FLCatch,i=ANY,j=ANY,drop=missing) :
  Returns an `FLCatch` where all the `FLQuant` slots have been subset by quant, year, unit, season, area and iter.
signature(x=FLBiol,i=ANY,j=ANY,drop=missing) :
  Returns an `FLBiol` where all the `FLQuant` slots have been subset by quant, year, unit, season, area and iter.
signature(x=FLCohort,i=ANY,j=ANY,drop=missing) :
  Describe method
signature(x=FLFleet,i=ANY,j=ANY) :
  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.
signature(x=FLFleet,i=ANY,j=missing) :
  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.
signature(x=FLMetier,i=ANY,j=missing) :
  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.
signature(x=FLlst,i=ANY,j=missing,value=missing) :
  Returns the specified element of the list. For example, for an `FLStocks` object, stocks[[1]] will return a single `FLStock`.
signature(x=FLFleet,i=ANY,j=missing) :
  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.
signature(x=FLMetier,i=ANY,j=missing) :
  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.
signature(x=FLlst,name=character,value=missing) :
  Describe method

### Author(s)

The FLR Team

### See Also

Extract

### Examples

    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]]

[Package FLCore version 2.2 Index]