Re: [R] Difficulty using the tryCatch() function

2021-02-08 Thread Greg Minshall
try removing the outermost '{'...'}'. e.g., { warning = ... } should be 'warning = ...'. Adn <- function(x,y) { out <- tryCatch( { x+y }, warning = function(cond) { message("There was a warning.") message("Here is the original warning message:")

Re: [R] Difficulty using the tryCatch() function

2021-02-07 Thread phil
Thanks so much for your speedy replies. Yes, removing those brackets did the trick. I was relying on an example in Stackoverflow at https://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r Philip On 2021-02-07 14:36, Jeff Newmiller wrote: Too many curly braces. warning and error

Re: [R] Difficulty using the tryCatch() function

2021-02-07 Thread Jeff Newmiller
Too many curly braces. warning and error need to be arguments to tryCatch. On February 7, 2021 11:30:59 AM PST, p...@philipsmith.ca wrote: >I need help using the tryCatch function. I have a function and I want >to >surround it with tryCatch to catch errors and thereby avoid stopping >execution o

[R] Difficulty using the tryCatch() function

2021-02-07 Thread phil
I need help using the tryCatch function. I have a function and I want to surround it with tryCatch to catch errors and thereby avoid stopping execution of my program if the function fails. In my reproducible example below I have used a very simply function that just adds two numbers together. M