append-methods: Append objects along the year dimension

append-FLCoreR Documentation

Append objects along the year dimension

Description

Method to append objects along the year dimensions, by extending, combining and substituting sections of them.

Usage

## S4 method for signature 'FLQuant,FLQuant'
append(x, values, after = dims(values)$minyear - 1)

## S4 method for signature 'FLStock,FLStock'
append(x, values, after = dims(values)$minyear - 1)

Arguments

x

the object to which the values are to be appended to.

values

to be included in the modified object.

after

a year dimname after with the values are to be appended.

Details

FLR objects are commonly manipulated along the year dimension, and the append method offers a simple interface for substituting parts of an object with another, or combine them into one, extending them when necessary. The object to be included or added to the first will be placed as defined by the year dimnames, unless the after input argument specifies otherwise.

Attributes like dimnames and units will always be taken from the first argument, unless the necessary chnages to dimnames$year

Value

An object of the same class as x with values appended.

Author(s)

The FLR Team

See Also

base::append

Examples

# append(FLQuant, FLQuant)
fq1 <- FLQuant(1, dimnames=list(age=1:3, year=2000:2010))
fq2 <- FLQuant(2, dimnames=list(age=1:3, year=2011:2012))
fq3 <- FLQuant(2, dimnames=list(age=1:3, year=2014:2016))

# Appends by dimnames$year
append(fq1, fq2)
# Appends by dimnames$year with gap (2011:2013)
append(fq1, fq3)
# Appends inside x
append(fq1, fq2, after=2009)
# Appends after end of x
append(fq1, fq2, after=2013)

# append(FLStock, FLStock)
data(ple4)
fs1 <- window(ple4, end=2001)
fs2 <- window(ple4, start=2002)
fs3 <- window(ple4, start=2005)

# Appends by dimnames$year
stock.n(append(fs1, fs2))

# Appends by dimnames$year with gap (2011:2013)
stock.n(append(fs1, fs3))

# Appends inside x
stock.n(append(fs1, fs3, after=2000))
# Appends after end of x
stock.n(append(fs1, fs3, after=2005))

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