A short description of the post.
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.
First things first, I recommend installing the latest version from the github repository.
library(devtools) install_github("hrbrmstr/slackr")
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:
api_token: xoxp-XXXXXXXXXXX-XXXXXXXXX-XXXXXXXXXX-XXXXXXXXX channel: #r username: rodney incoming_webhook_url: https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXX
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:
require(slackr) slackr_setup() slackr("This is an incoming piece of text from RStudio")
Which results in the following in my #r slack channel:
There is also a provision for sending output graphics like ggplot objects. Here is an example of heterozygosity in the Arapat data set.
library(gstudio) library(ggplot2) data(arapat) he <- genetic_diversity(arapat,mode="He") p <- ggplot( he, aes(x=Locus, y=He)) + geom_bar(stat="identity") + theme_bw() ggslack(p)
Which directly uploads the image to the channel as:
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:
require(devtools) load_all() build() install()
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.
For attribution, please cite this work as
Dyer (2016, July 8). The Dyer Laboratory: Collab Slack R. Retrieved from https://dyerlab.github.io/DLabWebsite/posts/2016-07-08-collab-slack-r/
BibTeX citation
@misc{dyer2016collab, author = {Dyer, Rodney}, title = {The Dyer Laboratory: Collab Slack R}, url = {https://dyerlab.github.io/DLabWebsite/posts/2016-07-08-collab-slack-r/}, year = {2016} }