The FLQuant
class is a six-dimensional array
designed to store most quantitative data used in fisheries and population
modelling.
FLQuant(object, ...)
# S4 method for missing
FLQuant(
object,
dim = rep(1, 6),
dimnames = "missing",
quant = NULL,
units = "NA",
iter = 1
)
# S4 method for vector
FLQuant(
object,
dim = rep(1, 6),
dimnames = "missing",
quant = NULL,
units = "NA",
iter = 1,
fill.iter = TRUE
)
# S4 method for array
FLQuant(
object,
dim = rep(1, 6),
dimnames = "missing",
quant = NULL,
units = "NA",
iter = 1,
fill.iter = TRUE
)
# S4 method for matrix
FLQuant(object, dim = lapply(dimnames, length), dimnames = "missing", ...)
# S4 method for FLQuant
FLQuant(
object,
quant = attributes(object)[["quant"]],
units = attributes(object)[["units"]],
dimnames = attributes(object)[["dimnames"]],
iter = dim(object)[6],
fill.iter = TRUE,
dim = attributes(object)[["dim"]]
)
Input numeric object
Additional arguments
Vector of dimension lengths
List of dimension names
Character vector for name of first dimension
Character vctor of units of measurement, see uom
Number of iterations, i.e. length of the 6th dimension
Should iterations be filled with the same content as the first?
The six dimensions are named. The name of the first dimension can be
altered by the user from its default, quant
. This could typically be
age
or length
for data related to natural populations. The
only name not accepted is 'cohort', as data structured along cohort should
be stored using the FLCohort
class instead. Other dimensions
are always names as follows: year
, for the calendar year of the
datapoint; unit
, for any kind of division of the population, e.g. by
sex; season
, for any temporal strata shorter than year; area
,
for any kind of spatial stratification; and iter
, for replicates
obtained through bootstrap, simulation or Bayesian analysis.
In addition, FLQuant
objects contain a units
attribute, of
class character
, intended to contain the units of
measurement relevant to the data.
Array must have 6 dimensions
Array must be of class numeric
Dimensions 2 to 6 must be named "year", "unit", "season", "area" and "iter"
The FLQuant
method provides a flexible constructor for objects of the class.
Inputs can be of class:
vector
:A numeric vector will be placed along the year dimension by default.
matrix
:A matrix will be placed along dimensions 1 and 2, unless otherwise specified by 'dim'. The matrix dimnames will be used unless overriden by 'dimnames'.
As above
If no input is given, an empty FLQuant
(NA) is returned, but dimensions and dimnames can still be specified.
Additional arguments to the constructor:
The units of measurement, a character
string.
The dimensions of the object, a numeric
vector of length 6.
A list
object providing the dimnames of the array. Only those different from the default ones need to be specified.
The name of the first dimension, if different from 'quant', as a character
string.
FLQuant
# creating a new FLQuant
flq <- FLQuant()
flq <- FLQuant(1:10, dim=c(2,5))
summary(flq)
#> An object of class "FLQuant" with:
#> dim : 2 5 1 1 1 1
#> quant: quant
#> units: NA
#>
#> Min : 1
#> 1st Qu.: 3.25
#> Mean : 5.5
#> Median : 5.5
#> 3rd Qu.: 7.75
#> Max : 10
#> NAs : 0 %
# Vectors are used column first...
dim(FLQuant(1:10))
#> [1] 1 10 1 1 1 1
# ...while matrices go row first.
dim(FLQuant(matrix(1:10)))
#> [1] 10 1 1 1 1 1
FLQuant(matrix(rnorm(100), ncol=20))
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7
#> 1 -0.510669 -0.181082 1.145809 1.358796 0.525276 -0.012403 -0.685477
#> 2 1.736481 -1.413347 0.459147 1.413355 0.914717 0.313311 0.943695
#> 3 0.057834 1.358472 0.692727 1.221155 -0.034119 0.713111 1.182915
#> 4 -0.946144 -0.836471 -2.361483 -0.074477 -0.051314 -0.244552 -1.632313
#> 5 0.074503 0.409306 0.113666 1.237297 -0.033011 -0.518365 0.049752
#> year
#> quant 8 9 10 11 12 13 14
#> 1 -0.570841 0.034321 0.528187 -0.725537 0.487438 -0.544244 0.738726
#> 2 -0.075935 0.372383 -0.870932 -1.056961 -0.387613 -0.287429 1.236167
#> 3 0.043232 -1.030049 1.159413 0.023433 0.465556 0.914090 -1.279472
#> 4 -0.068699 -0.810303 -0.762717 -0.753098 0.636620 -0.369246 -1.053636
#> 5 -0.385488 -0.675934 -1.437621 0.609299 0.111861 0.638880 -1.818369
#> year
#> quant 15 16 17 18 19 20
#> 1 1.164036 -1.159345 -1.095620 0.188095 1.942571 -2.918990
#> 2 0.076455 0.453254 1.473275 0.900973 -0.284791 1.359751
#> 3 0.201534 -0.712473 1.331012 -0.747585 1.392843 -0.556131
#> 4 0.413869 1.156182 -0.593759 -0.903444 0.641977 -0.745215
#> 5 0.317896 1.649048 -0.645864 0.337912 -0.886496 1.345473
#>
#> units: NA
FLQuant(array(rnorm(100), dim=c(5,2,1,1,1,10)))
#> An object of class "FLQuant"
#> iters: 10
#>
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2
#> 1 -0.543029(1.006) 0.761271(0.960)
#> 2 -0.199613(0.941) 0.181719(0.823)
#> 3 0.233727(0.985) -0.337888(0.867)
#> 4 -0.034069(0.992) 0.021014(1.292)
#> 5 -0.634101(0.301) -0.249129(0.603)
#>
#> units: NA
FLQuant(array(rnorm(100), dim=c(5,2)), iter=10)
#> An object of class "FLQuant"
#> iters: 10
#>
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2
#> 1 -0.68508(0) 0.80016(0)
#> 2 2.91591(0) -0.14505(0)
#> 3 0.33666(0) 2.85242(0)
#> 4 -0.74685(0) 1.35970(0)
#> 5 -2.68805(0) 0.40187(0)
#>
#> units: NA
# working with FLQuant objects
flq <- FLQuant(rnorm(200), dimnames=list(age=1:5, year=2000:2008), units='diff')
summary(flq)
#> An object of class "FLQuant" with:
#> dim : 5 9 1 1 1 1
#> quant: age
#> units: diff
#>
#> Min : -2.668931
#> 1st Qu.: -0.7435699
#> Mean : -0.1815546
#> Median : 0.02208487
#> 3rd Qu.: 0.4942287
#> Max : 1.486785
#> NAs : 0 %
flq[1,]
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 2000 2001 2002 2003 2004 2005 2006 2007
#> 1 1.10085 -0.20823 -0.32091 -0.17197 -0.27594 0.24512 -1.15769 0.86276
#> year
#> age 2008
#> 1 -1.13850
#>
#> units: diff
flq[,1]
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 2000
#> 1 1.10085
#> 2 -1.20650
#> 3 0.82368
#> 4 0.97022
#> 5 0.71679
#>
#> units: diff
flq[1,1] <- 0
units(flq)
#> [1] "diff"
quant(flq)
#> [1] "age"
plot(flq)
FLQuant()
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1
#> all NA
#>
#> units: NA
summary(FLQuant())
#> An object of class "FLQuant" with:
#> dim : 1 1 1 1 1 1
#> quant: quant
#> units: NA
#>
#> Min : NA
#> 1st Qu.: NA
#> Mean : NA
#> Median : NA
#> 3rd Qu.: NA
#> Max : NA
#> NAs : 100 %
FLQuant(1:10)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8 9 10
#> all 1 2 3 4 5 6 7 8 9 10
#>
#> units: NA
FLQuant(array(rnorm(9), dim=c(3,3,3)))
#> An object of class "FLQuant"
#> , , unit = 1, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 0.73224 0.67759 -0.69311
#> 2 -1.89720 -0.20544 -0.92559
#> 3 -1.03740 -2.50020 -0.93285
#>
#> , , unit = 2, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 0.73224 0.67759 -0.69311
#> 2 -1.89720 -0.20544 -0.92559
#> 3 -1.03740 -2.50020 -0.93285
#>
#> , , unit = 3, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 0.73224 0.67759 -0.69311
#> 2 -1.89720 -0.20544 -0.92559
#> 3 -1.03740 -2.50020 -0.93285
#>
#> units: NA
FLQuant(matrix(rnorm(12), nrow=4, ncol=3))
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 0.238221 0.678135 -0.944241
#> 2 -0.552774 -0.060273 0.587406
#> 3 -0.190999 0.491167 -2.085296
#> 4 -0.765253 -0.326995 0.823449
#>
#> units: NA
FLQuant(FLQuant(array(rnorm(9), dim=c(3,3,3)), units='kg'), units='t')
#> An object of class "FLQuant"
#> , , unit = 1, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 -0.988739 0.163115 0.072420
#> 2 0.301942 0.083651 -1.907245
#> 3 2.016773 0.052671 -0.305570
#>
#> , , unit = 2, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 -0.988739 0.163115 0.072420
#> 2 0.301942 0.083651 -1.907245
#> 3 2.016773 0.052671 -0.305570
#>
#> , , unit = 3, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 -0.988739 0.163115 0.072420
#> 2 0.301942 0.083651 -1.907245
#> 3 2.016773 0.052671 -0.305570
#>
#> units: t