sys.exit | R Documentation |
Similar to python's sys.exit. If used interactively, code execution is stopped with an error message, giving the provided status code. If used non-interactively (e.g. through Rscript), code execution is stopped silently and the process exits with the provided status code.
sys.exit(status = 0)
status |
exitcode for R process |
No return value, called for side effects
## Not run:
if (!file.exists("some.file")) {
cat("Error: some.file does not exist.\n", file = stderr())
sys.exit(1)
} else if (Sys.getenv("IMPORTANT_ENV") == "") {
cat("Error: IMPORTANT_ENV not set.\n", file = stderr())
sys.exit(2)
} else {
cat("Everything good. Starting calculations...")
# ...
cat("Finished with success!")
sys.exit(0)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.