Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPA-tutorial: FLXSA- retrospective analyses #17

Closed
JBLecomte opened this issue Jan 22, 2020 · 5 comments
Closed

VPA-tutorial: FLXSA- retrospective analyses #17

JBLecomte opened this issue Jan 22, 2020 · 5 comments

Comments

@JBLecomte
Copy link

Hello,

I am trying to reproduce the VPA tutorial for North Sea Plaice stock using FLXA:

After loading the data, I run the FLXSA function:

library(FLCore)
library(FLAssess)
library(FLXSA)
data(ple4)
data(ple4.indices)
xsa.control <- FLXSA.control()
ple4.xsa    <- FLXSA(ple4, ple4.indices, xsa.control)

and then I want to perform a retrospective analysis using:

retro.years <- 2012:2017 # updated values from online tutorial
ple4.retro <- tapply(retro.years, 1:length(retro.years), function(x){
  window(ple4,end=x)+FLXSA(window(ple4,end=x),ple4.indices)
})

I get the following error:
Error in lapply(assess@index, FLQuant) : negative length vectors are not allowed

It seems like I can't call 2 or more than 2 FLXSA in the same R session. Any idea, on how to perform a retrospective analysis using FLXSA ?

Thanks,

Here is my session info:

R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] FLXSA_2.6.3 FLAssess_2.6.3 FLCore_2.6.14 iterators_1.0.12 lattice_0.20-38
loaded via a namespace (and not attached):
[1] MASS_7.3-51.4 compiler_3.6.2 Matrix_1.2-18 tools_3.6.2 grid_3.6.2 stats4_3.6.2

@iagomosqueira
Copy link
Member

I have tested the same code, with packages installed from the repository, and it runs without problems in both Linux and Windows 10.

Can you try using only lapply?

ple4.retro <- lapply(retro.years, function(x){
  window(ple4,end=x)+FLXSA(window(ple4,end=x),ple4.indices)
})

@JBLecomte
Copy link
Author

Thanks for your answer, I was able to run all the code without error by using R directly. When I run the same code from RStudio I get the error, I mentioned above. I don't understand why Rstudio is causing the error, I will look into it tomorrow.

@JBLecomte
Copy link
Author

I found the issue, the most recent RStudio version (1.2.5033) is causing the error, while the RStudio
version 1.1.463 is running fine. I will send the issue to Rstudio. Thanks for your help.

@iagomosqueira
Copy link
Member

Thanks for letting us know. Is maybe one of packages loaded with RStudio redefining tapply in any way? Did it work in Rstudio using only lapply?

@JBLecomte
Copy link
Author

With the last version of RStudio (1.2.5033) both lapply and tapply fail. I sent an issue on the rstudio repo this morning to let them know about this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants