R/classes.R
, R/generics.R
, R/utilities.R
, and 1 more
fwdControl.Rd
The desired targets, limits and time steps used in fishery projections can be
specified by creating an object of class fwdControl
.
Constructor for fwdControl objects. Bare bones man pages. Better to look at the vignettes and tutorials.
fwdControl(target, iters, ...)
G(...)
# S4 method for data.frame,array
fwdControl(target, iters, ...)
# S4 method for data.frame,numeric
fwdControl(target, iters, ...)
# S4 method for data.frame,missing
fwdControl(target, iters, ...)
# S4 method for list,missing
fwdControl(target, iters, ...)
# S4 method for list,list
fwdControl(target, iters, ...)
# S4 method for missing,missing
fwdControl(target, iters, ...)
# S4 method for FLQuant,missing
fwdControl(target, quant, ...)
The target. Can be a data.frame, a list or missing.
target The iters. Can be an array, a numeric or missing.
Something
name of target to assign 'FLQuant' to, 'character'
target
The table of quantities and time steps used as target, data.frame.
iters
The values and limits for each target quantity and time step, array.
FCB
The matrix describing which FLCatch of which FLFishery catches which FLBiol. A matrix with 3 columns: F, C, and B.
Neque porro quisquam est qui dolorem ipsum.
All slots in the class have accessor and replacement methods defined that allow retrieving and substituting individual slots.
The values passed for replacement need to be of the class of that slot. A numeric vector can also be used when replacing FLQuant slots, and the vector will be used to substitute the values in the slot, but not its other attributes.
A construction method exists for this class that can take named arguments for
any of its slots. All slots are then created to match the requirements of the
class validity. If an unnamed FLQuant
object is provided, this is used
for sizing but not stored in any slot.
# CREATE targets on fishing mortality ('f') by year
target <- data.frame(year=2000:2010, value=rlnorm(11), quant='f')
fwc <- fwdControl(target=target)
# INSPECT fwdControl object
show(fwc)
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2000 f NA 1.047 NA
#> 2 2001 f NA 1.688 NA
#> 3 2002 f NA 6.143 NA
#> 4 2003 f NA 1.441 NA
#> 5 2004 f NA 2.183 NA
#> 6 2005 f NA 1.122 NA
#> 7 2006 f NA 1.498 NA
#> 8 2007 f NA 0.231 NA
#> 9 2008 f NA 0.610 NA
#> 10 2009 f NA 0.414 NA
#> 11 2010 f NA 1.134 NA
# Construct from data.frame and array
fcn <- fwdControl(data.frame(year=2000:2005, quant='f', value=0.5))
# Construct a fwdControl with some targets having multiple Biols, specified using the G() function
fwdControl(list(year=2000:2001, value=200, quant="catch", biol=G(1,2)),
list(year=2002:2003, value=100, quant="catch", biol=c(1,2)))
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 catch 1, 2 NA 200.000 NA
#> 2 2001 catch 1, 2 NA 200.000 NA
#> 3 2002 catch 1 NA 100.000 NA
#> 4 2003 catch 2 NA 100.000 NA
# Vector of values by year
fwdControl(data.frame(year=2010:2015, quant="f", value=seq(1, 1.3, length=6)))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2010 f NA 1.000 NA
#> 2 2011 f NA 1.060 NA
#> 3 2012 f NA 1.120 NA
#> 4 2013 f NA 1.180 NA
#> 5 2014 f NA 1.240 NA
#> 6 2015 f NA 1.300 NA
# Two targets, with ranges for one
fwdControl(data.frame(year=rep(2010:2015, each=2),
quant=c("f", "catch"),
min=c(rbind(NA, 20000)), max=c(rbind(NA, 30000)),
value=c(rbind(seq(1, 1.3, length=6), NA))))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2010 f NA 1.000 NA
#> 2 2010 catch 20000.000 NA 30000.000
#> 3 2011 f NA 1.060 NA
#> 4 2011 catch 20000.000 NA 30000.000
#> 5 2012 f NA 1.120 NA
#> 6 2012 catch 20000.000 NA 30000.000
#> 7 2013 f NA 1.180 NA
#> 8 2013 catch 20000.000 NA 30000.000
#> 9 2014 f NA 1.240 NA
#> 10 2014 catch 20000.000 NA 30000.000
#> 11 2015 f NA 1.300 NA
#> 12 2015 catch 20000.000 NA 30000.000
# Single target value
fwdControl(list(year=2010:2014, quant='catch', value=2900))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2010 catch NA 2900.000 NA
#> 2 2011 catch NA 2900.000 NA
#> 3 2012 catch NA 2900.000 NA
#> 4 2013 catch NA 2900.000 NA
#> 5 2014 catch NA 2900.000 NA
# One value per target (year)
fwdControl(list(year=2010:2014, quant='catch', value=seq(2900, 3500, length=5)))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2010 catch NA 2900.000 NA
#> 2 2011 catch NA 3050.000 NA
#> 3 2012 catch NA 3200.000 NA
#> 4 2013 catch NA 3350.000 NA
#> 5 2014 catch NA 3500.000 NA
# With 40 values (iters) in each target
fwdControl(list(year=2010:2014, quant='catch',
value=rnorm(200, seq(2900, 3500, length=5))))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2010 catch NA 2900.611(0.931) NA
#> 2 2011 catch NA 3049.848(1.459) NA
#> 3 2012 catch NA 3199.993(0.789) NA
#> 4 2013 catch NA 3349.880(1.167) NA
#> 5 2014 catch NA 3500.006(1.167) NA
#> iters: 40
#>
# lapply can be used to constructs a list
fwdControl(lapply(2005:2020, function(x) list(quant="catch",
value=runif(1, 1e5, 1e6), year=x)))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2005 catch NA 514343.113 NA
#> 2 2006 catch NA 585648.942 NA
#> 3 2007 catch NA 533662.032 NA
#> 4 2008 catch NA 145550.299 NA
#> 5 2009 catch NA 643066.307 NA
#> 6 2010 catch NA 595605.715 NA
#> 7 2011 catch NA 922054.813 NA
#> 8 2012 catch NA 819203.615 NA
#> 9 2013 catch NA 581274.116 NA
#> 10 2014 catch NA 634688.490 NA
#> 11 2015 catch NA 770554.039 NA
#> 12 2016 catch NA 952030.700 NA
#> 13 2017 catch NA 609629.757 NA
#> 14 2018 catch NA 526007.786 NA
#> 15 2019 catch NA 508107.818 NA
#> 16 2020 catch NA 457455.655 NA
fwdControl(lapply(2005, function(x) list(quant="catch",
value=runif(1, 1e5, 1e6), year=x)))
#> An object of class "fwdControl"
#> (step) year quant min value max
#> 1 2005 catch NA 309357.795 NA
# FLQuant, needs 'quant' name
fwdControl(FLQuant(0.2, dimnames=list(year=2000)), quant="fbar")
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 fbar 1 NA 0.200 NA