tags:

views:

74

answers:

3

Possible Duplicate:
Exception handling in R

Hi Everyone,

Does anyone have idea on how to catch an error or an exception in R.

Thanks,

+3  A: 

It really depends on what you mean by "catch". Look at tryCatch and withCallingHandlers.

Joshua Ulrich
A: 

Have you looked into stop? This will allow you to catch exceptions that you define.

Maiasaura
A: 

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))
Richie Cotton