Send messages to your devices from R with Pushbullet

Package RPushbullet, by Dirk Eddelbuettel et al., is a really cool gimmick to send messages to your devices from R. It is a great way to have R notify you of errors, or to let you know when it has finished executing a time-consuming task, so that you don’t need to check R periodically to know the status of your work.

Instructions

  • RPushbullet relies on the Pushbullet free messaging service, so the first thing you need to do is install the Pushbullet browser extension on your computer(s) and the Pushbullet app on your other devices;
  • Get your API key (or ‘Access Token’) from https://www.pushbullet.com/#settings/account;
  • Install necessary and useful packages:
if (!require(pacman)) install.packages('pacman'); library(pacman)
pacman::p_load(devtools)
if (!require(RPushbullet)) devtools::install_github("eddelbuettel/rpushbullet"); library(RPushbullet)
  • Set Pushbullet up:
RPushbullet::pbSetup() # you will need to provide your access token. As for the default device I'm not sure why having one would matter; I set mine to "none".
  • Send messages:
RPushbullet::pbPost("note", title="R is done crunching numbers", body="Human can get back to work.")

The package can also be used to report errors. For details, see: https://github.com/eddelbuettel/rpushbullet

from xkcd.com/303

Package RPushbullet complements well package evaluate by Hadley Wickham and Yihui Xie. I like to use evaluateto run entire scripts with:

replay(evaluate(file("SCRIPT.R"))) # (SCRIPT is just a placeholder)

It makes so that warnings and errors don’t interrupt the execution of the script. R simply continues executing the code and, when it’s done, it prints it to screen with any errors and warnings which might have appeared. This way you don’t have to worry that R will stop working just because it encountered an error, even if it doesn’t affect the rest of the script. Thanks to RPushbullet, once R is done running your code via evaluate you will receive a message without having to check R periodically.

Did you enjoy this? Consider joining my on-line course “First steps in data analysis with R” and learn data analysis from zero to hero!