To replicate this error you must first install the package MARSS. I also include the user guide.
https://cran.r-project.org/web/packages/MARSS/vignettes/UserGuide.pdf
The example on page 35 can be called with the
dat = t(harborSealWA)
dat = dat[2:nrow(dat),]
debugonce(MARSSkem)
kemfit = MARSS(dat)
When debugmode is triggered for MARSSkem in RStudio, you will find that it is not possible to set breakpoints! There is also a debug message at the top of the screen saying: "Debug location is approximate because source source code is not available". I assume this is why I can't set the breakpoints!
The problem is the error I am trying to locate (which is not present in the simple example shown) is found on 55th iteration and each iteration includes several for loops with 100 loops each! To step though by hand is simply not practical!
Q1.) Is there a way to set breakpoints for this function in R studio?
Q2.) If not what is my best option to locate this problem? (Ideally I don't want to go messing around with the package source code but I will if its the only option)
Thanks
Baz
The easiest way to do this (I think) is to make your own copy of the function, source it, and then play around with breakpoints.
To do this:
View(MARSS)
You should see the source pop-up. Now copy paste it, into a new script with mymarss <-
at the very start, save it (maybe as mymarss.R), and source it.
source(mymarss.R)
Now you can debug it like normal:
dat = t(harborSealWA)
dat = dat[2:nrow(dat),]
debugonce(mymarss)
kemfit = mymarss(dat)
And you can freely add/Remove breakpoints etc etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With