How do I get an R (version 3.4.2, CentOS 6.9) script to stop on Error instead of happily continuing on? My file :
$ cat tmp.R
a = 9
print(a)
print(b)
print(d)
print("Should never get here")
Running tmp.R
non-interactively it:
$ Rscript tmp.R
Looking for libraries in : ~/.R/3.4.2-lib
[1] 9
Error in print(b) : object 'b' not found
Error in print(d) : object 'd' not found
[1] "Should never get here"
Question : How do I get R to stop execution upon encountering an error?
I've tried things like options(error=stop)
and options(error=browser)
which work in the interactive case but not non-interactive Rscript example.