coerce: Methods for coercing objects between classes

coerceR Documentation

Methods for coercing objects between classes

Description

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.

Arguments

from

Object to be coerced into one of another class.

to

Name of the output class, character.

Details

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.

Value

An object of the requested class.

Author(s)

Iago Mosqueira. EC JRC.

See Also

coerce

Examples

# Single *catch* target
as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000))), "fwdControl")
# Single single *f* range
as(FLQuants(f=FLQuant(c(0.1, 0.9),
  dimnames=list(quant=c("min", "max"), year=2000))), 'fwdControl')
# Single *f* target, *value* specified
as(FLQuants(f=FLQuant(0.5, dimnames=list(quant=c("value"), year=2000))),
  'fwdControl')
# *catch* and *ssb* targets
as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000)),
   ssb_end=FLQuant(12000, dimnames=list(year=2000))), "fwdControl")
# *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')
# *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')
# targets with iters
as(FLQuants(fbar=propagate(FLQuant(seq(0.1, 0.5, by=0.1), dim=c(1,5)), 10)),
  "fwdControl")
# 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")

iagomosqueira/FLasher documentation built on Jan. 11, 2024, 12:58 a.m.