Possible Duplicate:
Exception handling in R
Hi Everyone,
Does anyone have idea on how to catch an error or an exception in R.
Thanks,
Possible Duplicate:
Exception handling in R
Hi Everyone,
Does anyone have idea on how to catch an error or an exception in R.
Thanks,
It really depends on what you mean by "catch". Look at tryCatch
and withCallingHandlers
.
Have you looked into stop
?
This will allow you to catch exceptions that you define.
Like Joshua said: use tryCatch
. Include an error
argument, which should be a function accepting one parameter (the error, typically called e
).
tryCatch(stop("you threw an error"), error = function(e) print(e$message))