14

I'm running a really long process and it would be great if there was a way to get R to Call, Email or Text me when its finished. Is there a way to setup an R-email script to be run when a program terminates or perhaps something that might employ IFTTT to send me a text message or Call in case I'm sleeping.

I'm using RStudio as my IDE so maybe there is such a feature through there.

If there is a way to track progress that would be nice too, but not 100% required

Adam
  • 648
  • 6
  • 18

1 Answers1

10

From this article:

http://alicebrawley.com/getting-r-to-notify-you-when-its-finished/

My general solution is to combine the R package mail, written by Lin Himmelmann, and variations on an IFTTT (If This, Then That) recipe. I use mail to send an email using functions in R, then IFTTT to notify me immediately of that particular email.

Once you’ve installed mail, use the following functions to send yourself an email when your code is completed.

#Have R email you when it's done running.
###Calculating - your wish is R's command.
library(mail)
#Send yourself an email - specify your preferred email address, subject, and message. The password is fixed at "rmail".
sendmail("xxxxx@xxxxx.com", subject="Notification from R", message="Conditions finished running!", password="rmail")

You can then use IFTT triggered by the email.

If you're sleeping next to your computer, consider also: Is there a way to make R beep/play a sound at the end of a script?

Community
  • 1
  • 1
C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134
  • Where is the email sent from? Do i need to provide my own email and password? – Adam Jul 13 '16 at 22:00
  • 1
    @adam it's sent from the package author's server. You just need to pass your receiving email address. – C8H10N4O2 Jul 13 '16 at 22:26
  • I know this should be closed by now, but `sendmail("myemail@domain.com")` started returning `"Problem!"`. Is there a reason for that? How would I fix this? I've tried multiple different addresses on different domains – Adam Jul 21 '16 at 21:32
  • 1
    @Adam I believe the API calls are throttled (to prevent spam). If you are doing a lot of these calls you may want to try `gmailr` or another email package that uses your imap account – C8H10N4O2 Jul 24 '16 at 01:11