coerce-methods: Convert Objects Between Classes

coerce-methodsR Documentation

Convert Objects Between Classes

Description

Objects of various FLCore classes can be converted into other classes, both basic R ones, like data.frame, and others defined in the package. For the specifics of the precise calculations carried out for each pair of classes, see below.

Arguments

object

Object to be converted.

Class

Name of the class to convert the object to, character.

Value

An object of the requested class.

FLArray to data.frame

The six dimensions of an FLArray are converted into seven columns, named quant (or any other name given to the first dimension in the object), year, unit, season, area, iter and data. The last one contains the actual numbers stored in the array. units are stored as an attribute to the data.frame. The year and data columns are of type numeric, while all others are factor.

FLPar to data.frame

The two or more dimensions of an FLPar objects are converted into three or more columns. For a 2D objects, they are named params, iter and data. The last one contains the actual numbers stored in the array, in a column type numeric, while all others are factor.

Author(s)

The FLR Team

See Also

base::as, base::coerce

Examples

# from FLQuant to data.frame
as(FLQuant(rnorm(100), dim=c(5, 20)), "data.frame")
# from FLPar to data.frame
as(FLPar(phi=rnorm(10), rho=rlnorm(10)), "data.frame")

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