Run Rscript and ignore errors?
Nick,
I don't know of a way to do what you want ... tell R to ignore all errors
... but, I do have a suggestion.
Since you regard these errors as "non-essential", why not edit your code to
reflect that? For example, instead of writing
plot(df$x1, df$y1)
write
if ("x1" %in% names(df) & "y1" %in% names(df)) plot(df$x1, df$y1)
... or something like that.
Jean
On Thu, Apr 23, 2015 at 12:28 PM, Nick Matzke <matzke at nimbios.org> wrote:
Hi R-help,
I've looked at google, the Rscript documentation and the Rscript --help
output and haven't found much on this. So, here's my question:
I have a rather long script that runs on various input datasets. It is
quite convenient to run the script from the Terminal command line with
"Rscript scriptname.R"
However, some datasets will cause errors. These are non-essential errors --
just some datasets don't have certain columns so certain parts of the
overall analysis don't produce figures etc. Yes, I could go through the
whole script and insert try() statements, etc. But I'm lazy.
So, is there a way to run Rscript or something similar, and just have it
ignore all errors (i.e., keep running through the script)? I.e., just like
what happens if you just copy-paste the whole script into the R window --
errors happen and are noted but the rest of the script keeps running.
Thanks very much for any help!!
Cheers!
Nick
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.