How to Slack from R

See how to send text messages and files directly from an R script to Slack with the slackr package

Using R to send a Slack message may sound like a parlor trick, but there are actually a lot of cases where that could come in handy. I’ve used Slack to send graphs to colleagues showing the latest web analytics trends. You can also use Slack to notify yourself or others when a lengthy R script finishes running.

Bob Rudis created the R package slackr that makes it easy to send Slack messages with R. It’s on CRAN, so you can install it with install.packages("slackr").

By far, the most complicated part of using slackr is initial setup. Fortunately, you only need to do that once. 

You’ll need to authorize R to use your specific Slack. Bob shows a sample configuration file to do this, in the following format:

api_token: YOUR_FULL_API_TOKEN
channel: #general
username: slackr
incoming_webhook_url: https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX

To continue reading this article register now