From 93f94d0d6884fd98dc5631e0d24ecac442e9a8e7 Mon Sep 17 00:00:00 2001 From: Iago Mosqueira Date: Thu, 11 Jan 2024 18:05:21 +0100 Subject: [PATCH] invALK can now use FLife::vonB --- DESCRIPTION | 2 +- R/FLS.R | 1 + R/length.R | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c3c20797..fb10f73b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: FLCore Title: Core Package of FLR, Fisheries Modelling in R -Version: 2.6.19.9104 +Version: 2.6.19.9105 Authors@R: c( person("Iago", "Mosqueira", email = "iago.mosqueira@wur.nl", role = "cre", comment=c(c(ORCID = "0000-0002-3252-0591"))), diff --git a/R/FLS.R b/R/FLS.R index 3e733b89..a27a32a4 100644 --- a/R/FLS.R +++ b/R/FLS.R @@ -316,6 +316,7 @@ setMethod("dbind", signature(x="FLS", y="FLS"), res <- lapply(setNames(nm=names(fqs[[1]])), function(i) do.call(dbind, c(lapply(fqs, '[[', i), dim=dim))) + # BUILD new object out <- do.call(class(x), res) # ASSIGN names diff --git a/R/length.R b/R/length.R index b1f8d233..1e12743e 100644 --- a/R/length.R +++ b/R/length.R @@ -63,9 +63,15 @@ invALK <- function(params, model=vonbert, age, cv=0.1, lmax=1.2, bin=1, # FOR each age bins <- seq(0, ceiling(linf * lmax), bin) - lparams <- as(FLPar(params), "list") - len <- do.call(model, c(list(age=age), - lparams[names(lparams) %in% names(formals(model))])) + + # METHOD + if(isS4(model)) + len <- do.call(model, list(age=age,params=params)) + else { + lparams <- as(FLPar(params), "list") + len <- do.call(model, c(list(age=age), + lparams[names(lparams) %in% names(formals(model))])) + } if(is.null(reflen)) { sd <- abs(len * cv)