Have you ever found a GitHub repository with an interesting R package?
How cool would it be to try it out without having to deal with installation and dependencies?
Fortunately, it is possible thanks to the BinderHub - the server technology that turns computational material (e.g. Jupyter Notebook) into interactive computational environments in the cloud.
Here you can see an example of such an interactive notebook. Loading may take around 15 seconds.
How to use it?
Using these interactive notebooks is very convenient because all you have to do is just look for the badge like this one:
and click on it. You can modify chunks with code and re-run them by pressing
Ctrl+Enter or S
Let’s learn more about the Binder.
How does it work?
It is best to let the authors describe Binder themselves. Below you can read a part of the Binder documentation.
Binder makes it simple to generate reproducible computing environments from a Git repository. Binder uses the BinderHub technology to generate a Docker image from this repository. The image will have all the components that you specify along with the Jupyter Notebooks inside. You will be able to share a URL with users that can immediately begin interacting with this environment via the cloud. Binder’s goal is to enable as many analytic workflows as possible.
Now let’s see how to build a Binder repository.
Turn your GitHub repository into a collection of interactive notebooks
In the Binder documentation, you will find detailed and extended instructions. Here, I will show a minimal example of the basic configuration in three easy steps.
You need a GitHub repository with at least one Jupyter notebook.
If you do not have Jupyter installed on your computer, you can create a notebook online. Just chose the Try Jupyter with R option on the Jupyter website. However, it may be difficult to load some of the packages, so I suggest using the Jupyter installed locally on your computer.
Create configuration files in your GitHub repository.
Those files specify the requirements for building a Binder repository. They may be placed in the repository’s root or in a
Here you’ll find a toy example with configuration files. In your repository you should have at least two of them:
runtime.txtwith specified MRAN snapshot that is formatted like:
The example file content:
install.Rthat will be executed during the build and is used to install libraries. The example file content:
install.packages("auditor") install.packages("DALEX") install.packages("randomForest")
If your GitHub repository contains an R package and is integrated with Travis CI, don’t forget to exclude configuration files from the build by adding them to
.Rbuildignore. Otherwise, you’ll get a warning and notes during the package check.
- Building and launching a Binder repository
Now, you’re ready to launch your Binder repository. To do this, you need to visit MyBinder.org.
On the MyBinder.org, in the How it works section, you will find clear instructions on how to build and launch a Binder repository.
In short, you should provide a URL or a GitHub repository name. Optionally, you can specify a path to a notebook file which will be opened in your browser after building. The building may take some time. It depends on the packages that need to be installed. Afterward, the binder will build a Docker image and then will automatically send you to a live Jupyter session connected to your repository.