Collab <- Slack + R

I just ran across an R package that allows you to integrate your R workflow into the Slack environment. Really cool. Below I show how to set it up and to post output of your analyses to slack channels for your team as well as to register notifications.

Screen Shot 2016-07-08 at 11.17.56 AM

First things first, I recommend installing the latest version from the github repository.


Now you have to set up a config file. I think it looks for it in ~/.slackr It is a normal Debian Control File (DCF) format. Here is my example one:

channel: #r
username: rodney

You need to get the api_token and the incoming_webhook_url from slack itself. Once you have that file saved, when you want to setup the slackr environment, you load it in and can send messages such as:

slackr("This is an incoming piece of text from RStudio")

Which results in the following in my #r slack channel:

Screen Shot 2016-07-08 at 1.41.41 PM

There is also a provision for sending output graphics like ggplot objects. Here is an example of heterozygosity in the Arapat data set.

he <- genetic_diversity(arapat,mode="He")
p <- ggplot( he, aes(x=Locus, y=He)) + geom_bar(stat="identity") + theme_bw()

Which directly uploads the image to the channel as:

Screen Shot 2016-07-08 at 1.46.04 PM

Very Cool!

There is a slight problem though. The current version of the slackr library has an error in it associated with (perhaps) a recent change in the Slack API that has not been fixed by the developer.

For me to get this to work, I had to compile the package myself after making the following change in one file. To fix it, do the following:

  1. Download (or checkout) the repository from github at:

  2. Open the project in RStudio

  3. Open the R file names slackr_utils.R

  4. In the function named slackr_ims the last line (line 117) is something like dplyr::left_join( %some stuff% )

  5. Replace this line with suppressWarnings( merge(users, ims, by.x=”id”, by.y=‘user’) )

  6. The compile and install the package as:


  7. It should work just fine.

Hopefully, on the next time that this package is updated by the author, the left_join() problem will have been resolved. This issue had been marked as “resolved” in the github issues a while back but apparently not pushed to the repository.

Father, Husband, Brewer, Professor

Middle aged guy trying to keep it all together and figure out how to best navigate the world as it is. Technology geek, practitioner of fermentation sciences, researcher, biologist.