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.
name(object, ...) desc(object, ...) range(x, i) <- value units(x) <- value catch(object, ...) catch.n(object, ...) 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, ...) fitted(object, ...) rec(object, ...) rec.obs(object, ...) catch.q(object, ...) discards.sel(object, ...) landings.sel(object, ...) params(object, ...)
The required slot, for an accessor method, or invisible modifies the object, for the replacement one.
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.
FLQuant
, FLStock
, FLIndex
,
FLBiol
, predictModel
data(ple4) # To access the catch slot in an FLStock, use catch(ple4)#> An object of class "FLQuant" #> , , unit = unique, season = all, area = unique #> #> year #> age 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 #> all 78423 88240 109238 117138 118331 125272 148170 147357 139820 166784 #> year #> age 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 #> all 163178 139503 142896 160026 136932 142495 143883 157804 195154 167089 #> year #> age 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 #> all 176691 159727 213422 171235 172671 204286 218424 226930 220928 296876 #> year #> age 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 #> all 342985 311635 277738 228734 229607 183284 152242 134392 120316 133797 #> year #> age 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 #> all 179957 175002 151708 126142 182578 125884 145390 117702 111060 121205 #> year #> age 2007 2008 #> all 90283 96040 #> #> units: t# 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')#> Method Definition: #> #> function (object, ...) #> { #> .local <- function (object) #> return(slot(object, "catch")) #> .local(object, ...) #> } #> <environment: 0xca06518> #> #> Signatures: #> object #> target "FLS" #> defined "FLS"