Re: [Rd] [tryExcept] New try Function

2018-11-26 Thread Andrew Redd
I have two related packages that are already submitted to CRAN but are awaiting approval. They are part of the R Documentation Task Force efforts to improve documentation. The exact function you are referring to I have called `catch_condition()` and included it in my `testextra` package. You mig

Re: [Rd] [tryExcept] New try Function

2018-11-23 Thread Ernest Benedito
Hi Emil, First, thanks for the response. As you mentioned, a lot of times tryCatch does the work, as you can return a value. However, sometimes it is useful to assign several variables when an error occurs. You could do it with <<-, but I prefer to reduce it's usage unless completely necessary. I

Re: [Rd] [tryExcept] New try Function

2018-11-23 Thread Emil Bode
Hi Ernest, To start: I don't see an attachment, I think they're not (always) allowed on this mailing-list. If you want to send something, text is your safest bet. But regarding the issue of tryCatch: I think you're not fully using what it already can do. In almost all circumstances I've encounte

[Rd] [tryExcept] New try Function

2018-11-22 Thread Ernest Benedito
Hi everyone, When dealing with errors, sometimes I want to run a bunch of code when an error occurs. For now I usually use a structure such as: res <- tryCatch(expr, error = function(cond) cond) # or try(expr) if (inherits(res, “error”)) # or inherits(res, “try-error”) # a bunch of code I th