accessors: accessor and replacement methods for FLCore classes

accessorsR Documentation

accessor and replacement methods for FLCore classes

Description

All S4 classes defined in FLCore have methods for accessing and replacing any of their slots. These methods are named as the slot, and will return the content of the slot, for the accessor method, or modify it with the provided value.

Usage

name(object, ...)

desc(object, ...)

range(x, i) <- value

catch(object, ...)

catch.n(object, ...) <- value

catch.wt(object, ...)

discards(object, ...)

discards.n(object, ...)

discards.wt(object, ...)

landings(object, ...)

landings.n(object, ...)

landings.wt(object, ...)

m(object, ...)

stock(object, ...)

stock.n(object, ...)

stock.wt(object, ...)

m.spwn(object, ...)

harvest(object, catch, ...)

harvest.spwn(object, ...)

mat(object, ...)

n(object, ...)

m(object, ...)

wt(object, ...)

fec(object, ...)

spwn(object, ...)

effort(object, metier, ...)

type(object, ...)

distr(object, ...)

distribution(object, ...)

index(object, ...)

index.var(object, ...)

catch.n(object, ...)

catch.wt(object, ...)

sel.pattern(object, ...)

index.q(object, ...)

model(object, ...)

logl(object, ...)

gr(object, ...)

initial(object, ...)

logLik(object, ...)

vcov(object, ...) <- value

hessian(object, ...)

logerror(object, ...)

details(object, ...)

residuals(object, ...) <- value

fitted(object, ...)

rec(object, ...)

rec.obs(object, ...)

catch.q(object, ...)

discards.sel(object, ...)

landings.sel(object, ...)

params(object, ...)

## S4 replacement method for signature 'FLS,FLQuants'
catch(object) <- value

Arguments

object

The object from which a slot is to be extracted or replaced

value

Object to be inserted into the relevant slot

Details

Accessors and replacement methods, with some exception, are created at build time by calls to the createFLAccessors function. An accessor method is created for each slot, with simply calls slot() on the relevant slot name. For slots of class FLQuant, or FLArray-based, two methods are created: one if value is of class FLQuant, and another for value being a numeric vector. The later would insert the vector into the slot structure, using R's recycling rules.

Users are encouraged to use the accessor methods, rather than the '@' operator or the slot() method, to isolate code from the internal structure of the class. If a slot was to be altered or deleted in the future, a method would be provided to return the same value, computed from other slots.

Some of these methods might already not access directly an slot, and instead carry out a calculation to return the requested value, depending on the class being called with. Please refer to the particular method implementation to see if this is the case.

Accessor methods for slots of class predictModel behave differently depending on the compute argument. Please refer to the relevant help page for further clarification.

An object of class FLQuants, containing three elements named catch, catch.n and catch.wt, as returned by computeCatch, can be assigned directly to an object using catch<-.

Value

The required slot, for an accessor method, or invisible modifies the object, for the replacement one.

Author(s)

The FLR Team

See Also

FLQuant, FLStock, FLIndex, FLBiol, predictModel

Examples


data(ple4)

# To access the catch slot in an FLStock, use
catch(ple4)

# while to modify it, do
catch(ple4) <- catch(ple4) * 2

# A number can be used as input, to be recycled
m(ple4) <- 0.3
# same as a longer vector, by age
m(ple4) <- 0.4^(seq(1, 2, length=10))

# To see the methods defined by createFLAccessors, run, for example
getMethod('catch', 'FLS')

# Assign the 3 catch slots
catch(ple4) <- computeCatch(ple4, slot="all")

flr/FLCore documentation built on May 4, 2024, midnight