Git Product home page Git Product logo

r_with_python's Introduction

R + Python Binder Example

This repo builds on the r binder and jupyter lab binder and is complementary to the multi-language-demo binder with examples on using both R and python in both Jupyter Lab and RStudio.

  • Launch in Jupyter Lab: Binder
  • Launch in RStudio: Binder

Example files included:

  • python_example_for_Jupyter.ipynb - Notebook file using a python kernel for working in Jupyter
  • R_example_for_Jupyter.ipynb - Notebook file using an R kernel for working in Jupyter
  • python_example_for_RStudio.Rmd - RMarkdown file with python code chunks for working in RStudio
  • R_example_for_RStudio.Rmd - RMarkdown file with R code chunkcs for working in RStudio

Note: to mix R and python in a single Jupyter notebook, use cell magic as demonstrated in the multi-language-demo binder examples. To mix R and python in a single RMarkdown file (and exchange information between them), make use of reticulate. The latter requires RStudio 1.2+ to work interactively, which is not yet installed as the default binder version (i.e. interactive python and python plots will not yet work in RMarkdown and the above example file uses reticulate for plotting in the knitted file).

Binder Setup

Modify the files in the binder sub-directory to specify required dependencies for R and python. Binder will generate a docker image for your repository after every change to the repo and then will re-use the docker image on subsequent launches. This means that the first time you launch binder for the latest version of your branch, it may take some time to launch (especially with a lot of R dependencies which are all compiled from source) but will be fast for everyone else afterwards. Switching between RStudio vs. Jupyter Lab as the IDE is accomplished easily by changing the binder link as described below - the required dependencies for both are automatically installed and do not need to be explicitly listed in the respective configuration files.

Important: binder will only work for public repositories. If your repository is private, you will have to make it public in the repository settings before you can launch it in binder.

R

  • modify the binder/runtime.txt file to specify which R date snapshot should be used (the MRAN network keeps a daily snapshot)
  • modify the binder/install.R file to make sure all dependencies are specified. Dependencies can be from CRAN, bioconductor or GitHub. Since GitHub hosted libraries are not part of the MRAN snapshot, it is best to specify a commit or release tag to ensure that a compatible version of the package is installed in the binder.

Python

  • modify the binder/environment.yml file to specify the dependencies. The file is a standard conda environment config file and thus supports conda packages, version definitions, multiple source channels as well as pip installations.
  • modify the binder/postBuild file for any JupyterLab extensions or other direct install commands

Binder Link

Jupyter Lab

  • modify the following link to launch your repo in an RStudio binder (USER, REPO, BRANCH): http://mybinder.org/v2/gh/USER/REPO/BRANCH?urlpath=lab
  • modify the following markdown code to create a launch badge like the one at the top this README: [![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/v2/gh/USER/REPO/BRANCH?urlpath=lab)

RStudio

  • modify the following link to launch your repo in an RStudio binder (USER, REPO, BRANCH): http://mybinder.org/v2/gh/USER/REPO/BRANCH?urlpath=rstudio
  • modify the following markdown code to create a launch badge like the one at the top of this README: [![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/v2/gh/USER/REPO/BRANCH?urlpath=rstudio)

r_with_python's People

Contributors

betatim avatar choldgraf avatar sebkopf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

r_with_python's Issues

500 : Internal Server Error when launching rstudio

I forked this repo, made no commits, and entered the forked repo's url
https://github.com/marskar/r_with_python
into mybinder.org.

When I try to launch rstudio using the url I obtained from mybinder.org
https://mybinder.org/v2/gh/marskar/r_with_python/master?urlpath=rstudio
I get an error: 500 : Internal Server Error.

On the error page, I can switch to the classic notebook or JupyterLab by editing the url.
Launching the classic notebook or JupyterLab works fine.
https://mybinder.org/v2/gh/marskar/r_with_python/master
https://mybinder.org/v2/gh/marskar/r_with_python/master?urlpath=lab

The launch rstudio link for your repo
http://mybinder.org/v2/gh/binder-examples/r_with_python/master?urlpath=rstudio
works fine.

I noticed that after rstudio launches the url based on your repo has a token at the end, something like /rstudio/?token=SZlYyBCaTY2XUIVknZFxHw, whereas my rstudio url just ends /rstudio/.

How can I launch rstudio from my repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.