Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mse
Title: Tools for Running Management Strategy Evaluations using FLR
Version: 2.4.8.9011
Version: 2.4.9
Authors@R: c(person(given = "Iago", family = "Mosqueira",
role = c("aut", "cre"), email = "[email protected]"),
person("Ernesto", "Jardim", email = "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ exportClasses(

exportMethods(
"[",
"append",
"args",
"args<-",
"biol",
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# mse 2.5.0

## NEW FEATURES

- `append(FLombf, FLombf, after)` method to join two operating models at a year boundary.

# mse 2.4.9

## BUG FIXES
Expand Down
54 changes: 54 additions & 0 deletions R/FLombf-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,60 @@ setMethod("combine", signature(x = "FLombf", y = "FLombf"), function(x, y, ...){
})
# }}}

# append {{{

#' Append two FLombf objects along the year dimension
#'
#' Joins two \code{FLombf} objects along the year axis: the first object is
#' windowed to \code{after}, and the second from \code{after + 1} to its last
#' year. The two windowed pieces are then combined using \code{FLCore::append}
#' on the underlying \code{FLBiols} and \code{FLFisheries} slots.
#'
#' @param x An \code{FLombf} object, used up to year \code{after}.
#' @param values An \code{FLombf} object, used from year \code{after + 1}.
#' @param after Integer year. The last year taken from \code{x}. Defaults to
#' the last year of \code{x}.
#'
#' @return A new \code{FLombf} object spanning the years of \code{x} up to
#' \code{after} joined with the years of \code{values} from \code{after + 1}.
#'
#' @examples
#' # Split an FLombf at year 2020 and re-join
#' om1 <- window(om, end=2020)
#' om2 <- window(om, start=2021)
#' om3 <- append(om1, om2, after=2020)
#'
#' @rdname FLombf-class
#' @aliases append,FLombf,FLombf-method

setMethod("append", signature(x="FLombf", values="FLombf"),
function(x, values, after=dims(x)$maxyear) {

after <- as.integer(after)

# WINDOW x up to 'after'
x <- window(x, end=after)

# WINDOW values from 'after + 1'
values <- window(values, start=after + 1L)

# APPEND biols
biols(x) <- FLBiols(Map(append, x=biols(x), values=biols(values)))

# APPEND fisheries: each FLFishery, then each FLCatch within
fisheries(x) <- FLFisheries(Map(function(fx, fv) {
# APPEND the FLFishery-level slots (effort, etc.)
out <- append(fx, fv)
# APPEND every FLCatch within the fishery
[email protected] <- Map(append, [email protected], [email protected])
names(out) <- names(fx)
return(out)
}, fx=fisheries(x), fv=fisheries(values)))

return(x)
}
) # }}}

# deviances {{{

setMethod("deviances", signature(object="FLombf"),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ You are welcome to:

- Submit suggestions and bug-reports at: <https://github.com/flr/mse/issues>
- Send a pull request on: <https://github.com/flr/mse/>
- Authors: Iago Mosqueira, WUR. Ernesto Jardim, IPMA.
- Authors: Iago Mosqueira, WMR. Ernesto Jardim, IPMA.
- Maintainer: Iago Mosqueira, WMR.
Loading