Possible duplicate:Exception handling in R
Does anyone have an idea on how to catch an error or exception in R?
As Joshua said: use tryCatch. Include an argument error, which should be a function that takes one parameter (an error, commonly called e).
tryCatch
error
e
tryCatch( stop("you threw an error"), error = function(e) { print(e$message) # or whatever error handling code you want } )
It really depends on what you mean by "trick". Take a look tryCatchand withCallingHandlers.
withCallingHandlers
stop? , .
stop