Skip to content

Instantly share code, notes, and snippets.

@javieroot
Forked from nassimhaddad/tryCatch.R
Last active January 10, 2018 22:39
Show Gist options
  • Save javieroot/73c26d8a699e262d4ca7ed9728e155d3 to your computer and use it in GitHub Desktop.
Save javieroot/73c26d8a699e262d4ca7ed9728e155d3 to your computer and use it in GitHub Desktop.
using trycatch
result = tryCatch({
is.numeric(1)
# return(TRUE)
# no poner return, ya que da error, solo poner TRUE al final si se quiere
# una salida TRUE
# TRUE
# return(0)
0
}, warning = function(w){
message("Warning")
return(TRUE)
}, error = function(e){
message("Error")
return(FALSE)
}, finally = {
message("Final de función")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment