A call to as(from, 'to') will coerce the object from, of a certain class, to one of class to, as specified in the method.
Object to be coerced into one of another class.
Name of the output class, character.
An object of the requested class.
An object of class FLQuants can be coerced into a fwdControl, through a call to as.data.frame. The name of the element, or elements, in the object specifies the 'quant' in fwdControl. The 'quant' in the FLQuant object, the name of the first dimension, is ignored unles is one of 'min', 'value' or 'max'. See the examples below on how to pass one or more FLQuant objects to fwd.
coerce
# Single *catch* target
as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000))), "fwdControl")
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 catch 1 NA 4500.000 NA
# Single single *f* range
as(FLQuants(f=FLQuant(c(0.1, 0.9),
dimnames=list(quant=c("min", "max"), year=2000))), 'fwdControl')
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 f 1 0.100 NA 0.900
# Single *f* target, *value* specified
as(FLQuants(f=FLQuant(0.5, dimnames=list(quant=c("value"), year=2000))),
'fwdControl')
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 f 1 NA 0.500 NA
# *catch* and *ssb* targets
as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000)),
ssb_end=FLQuant(12000, dimnames=list(year=2000))), "fwdControl")
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 catch 1 NA 4500.000 NA
#> 2 2000 ssb_end 1 NA 12000.000 NA
# *f* target and *catch* limits
as(FLQuants(f=FLQuant(0.5, dimnames=list(year=2000)),
catch=FLQuant(c(100, 4000), dimnames=list(quant=c("min", "max"), year=2000))),
'fwdControl')
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 f 1 NA 0.500 NA
#> 2 2000 catch 1 100.000 NA 4000.000
# *f* target and *catch* minimum
as(FLQuants(f=FLQuant(0.5, dimnames=list(year=2000)),
catch=FLQuant(c(100), dimnames=list(quant=c("min"), year=2000))), 'fwdControl')
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 2000 f 1 NA 0.500 NA
#> 2 2000 catch 1 NA 100.000 NA
# targets with iters
as(FLQuants(fbar=propagate(FLQuant(seq(0.1, 0.5, by=0.1), dim=c(1,5)), 10)),
"fwdControl")
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 1 fbar 1 NA 0.100 NA
#> 2 2 fbar 1 NA 0.200 NA
#> 3 3 fbar 1 NA 0.300 NA
#> 4 4 fbar 1 NA 0.400 NA
#> 5 5 fbar 1 NA 0.500 NA
#> iters: 10
#>
# targets with different iters
as(FLQuants(fbar=FLQuant(rep(seq(0.1, 0.5, by=0.1), each=10),
dim=c(1,5,1,1,1,10))), "fwdControl")
#> An object of class "fwdControl"
#> (step) year quant biol min value max
#> 1 1 fbar 1 NA 0.300(0.148) NA
#> 2 2 fbar 1 NA 0.300(0.148) NA
#> 3 3 fbar 1 NA 0.300(0.148) NA
#> 4 4 fbar 1 NA 0.300(0.148) NA
#> 5 5 fbar 1 NA 0.300(0.148) NA
#> iters: 10
#>