You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the "depends" list in the "cache" function, when I put in a variable that does not exist (generally by accident), the error I get is
"Error in if (nrow(depends.hash) >= 1) { : argument is of length zero"
Unless you know the mistake you've made, its hard to tell from this error message that you've made a typo in the your "depends" variables. Would probably save some head scratching if the error was something more like
"Error, variable "x" in dependencies is not found in the current environment"
PS: Here is some code that will generate the error for me:
cache("new_var", {
x <- 56
}, depends = c("old_var"))
The text was updated successfully, but these errors were encountered:
I don't think this is possible. The cache code calls eval on the code in the curly braces. eval doesn't have error trapping capabilities. That is, it doesn't return a string with any errors it encountered. Instead if there is an error, the error is thrown by eval, which is what you are seeing.
@connectedblue would you have any thoughts on how to trap errors in the cache function?
Hi all
It's been a while since I wrote R code - I've spent the last 9 months in
back in python (where funnily enough I had to also write some caching
utilities).
However, I'll put this on my to do list to have a look at. I vaguely
remember some error trapping techniques in a project somewhere.
In the "depends" list in the "cache" function, when I put in a variable that does not exist (generally by accident), the error I get is
"Error in if (nrow(depends.hash) >= 1) { : argument is of length zero"
Unless you know the mistake you've made, its hard to tell from this error message that you've made a typo in the your "depends" variables. Would probably save some head scratching if the error was something more like
"Error, variable "x" in dependencies is not found in the current environment"
PS: Here is some code that will generate the error for me:
cache("new_var", {
x <- 56
}, depends = c("old_var"))
The text was updated successfully, but these errors were encountered: