RPushbullet is an R client for the wonderful Pushbullet messaging / notification system.
Pushbullet is an awesome (and free) little service that acts as a message broker. You sign up, and get a key to use the API. You then install the “app” on your smartphone or Chrome browser (and obtain a device id for of these). You can also query your account with the
pbDevices() function to retrieve these ids.
Presto. Now you can send messages between them by invoking
Pushbullet also exposes an API which we use here. You can send a (text) note, a link, an image, an address, a file… They appear near instaneously (ie much faster than email would) and immediately “do the right thing”. A link opens the page in the browser, images are displayed, addresses are mapped on Google Maps etc pp.
So an obvious use case is to end that long simulation and have a summary chart pushed – so when you’re hanging on the couch or in the bar you get results right there and then.
Upon startup, the package attempts to read a file ‘rpushbullet.json’ from your home directory. As the extension suggests, the file is in JSON format and immediately converted to a list stored inside an environment accessible to the package. The JSON file should contain a variable ‘key’ for the API key, as well as a variable ‘devices’ with one or more device keys.
One quick way to create such a file is to revert the
fromJSON() call done when the file is read and do something like
where the values for the list elements
devices should be, respectively, your API key and one or more device ids. There are optional fields
defaultdevice as well.
Alternatively, you can also set these values as
option() elements in your R startup files, or simply pass them as function arguments (but that last method is really not ideal for scripted use where you may accidentally expose them). These option are all documented in the main package help page.
A simple example is
With a resource file properly setup, you can just do something like the following
and a message like the image following below should pop up (if messaging directed to the browser):
More examples are in the documentation. There are also two short blog posts by Karl Broman: the first discusses notifications from R, and the second one shows a neat trick to invoke RPushbullet in R error condition handlers).
Pushover is of course a very similar idea, but (was at the time I looked into this) iOS only whereas I am an Android user. Also, their phone app costs money, which is also a little less cool. So I never looked much into the notifyR package using this service.
RPushbullet is licensed under the GPL (version 2 or later).