Rog*_*ger 2 error-handling notifications r
目前,我很喜欢在 R 脚本运行完毕后收到电子邮件通知,这要归功于该mail软件包。
但是,我想知道如果脚本因遇到错误而无法完成运行,是否可以让 R(或 RStudio 或其他东西)通知我?电子邮件将是最好的传递方式。
当我在远程计算机上运行代码或离开计算机时,这将非常有用。
获取 PushBullet 消息:http://cran.r-project.org/web/packages/RPushbullet/index.html
\n\n或者给自己发一封电子邮件:http ://cran.r-project.org/web/packages/mailR/
\n\n并使用 tryCatch...
\n\na <- tryCatch({\n\xc2\xa0\xc2\xa0\xc2\xa0 source("your_script.R")\n}, warning = function(w) {\n\xc2\xa0\xc2\xa0\xc2\xa0 warning-handler-code\n}, error = function(e) {\n\xc2\xa0\xc2\xa0\xc2\xa0 send mail, pushbullet, etc...\n}, finally = {\n\xc2\xa0\xc2\xa0\xc2\xa0 cleanup\n}\nRun Code Online (Sandbox Code Playgroud)\n