Skip to content

Instantly share code, notes, and snippets.

@msuzen
Created June 10, 2017 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msuzen/d25f7e729198b351fd5f2a3abc024d2b to your computer and use it in GitHub Desktop.
Save msuzen/d25f7e729198b351fd5f2a3abc024d2b to your computer and use it in GitHub Desktop.
Simple try/catch in R
R Notes:
# tryCath Example
# http://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r
out <- tryCatch({
pp <- find.package(packageName,lib.loc=lib.loc),
},
error=function(cond) {
cat("packageName or lib.loc in ",
"packageRSubdirectoryLinesOfCode",
"does not seem to exist \n")
return(NULL)
},
warning=function(cond) {
cat("packageName or lib.loc in ",
"packageRSubdirectoryLinesOfCode",
"does not seem to exist \n")
return(NULL)
},
finally={}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment