问题
I currently enjoy receiving email notifications when my R scripts have finished running, thanks to the mail
package.
However, I would like to know if it's possible to have R (or RStudio, or something else) notify me if a script fails to finish running because it has encountered an error? Email would be the best delivery method.
This would be extremely useful when I'm running code on a remote machine, or when I'm away from my computer.
回答1:
Get a pushbullet message: http://cran.r-project.org/web/packages/RPushbullet/index.html
Or send yourself an email: http://cran.r-project.org/web/packages/mailR/
And use tryCatch...
a <- tryCatch({
source("your_script.R")
}, warning = function(w) {
warning-handler-code
}, error = function(e) {
send mail, pushbullet, etc...
}, finally = {
cleanup
}
来源:https://stackoverflow.com/questions/28886696/how-can-i-make-r-send-an-alert-if-it-encounters-an-error