How to Debug R Script with tryCatch Function (Example Code)
In this article, I’ll explain how to debug R codes using the tryCatch function in the R programming language.
Example: Handling Error Message with tryCatch() Function in R
tryCatch( # Using tryCatch() function expr = { # Setting up the expression "five" * "seven" message("No Errors.") }, error = function(e){ # Error message that should be returned message("ERROR!!!") } ) # ERROR!!! |
tryCatch( # Using tryCatch() function expr = { # Setting up the expression "five" * "seven" message("No Errors.") }, error = function(e){ # Error message that should be returned message("ERROR!!!") } ) # ERROR!!!