├── Dockerfile ├── README.md ├── index.R ├── instructions.ipynb └── rstudio_ui.png /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rocker/binder:3.4.2 2 | 3 | # Copy repo into ${HOME}, make user own $HOME 4 | USER root 5 | COPY . ${HOME} 6 | RUN chown -R ${NB_USER} ${HOME} 7 | USER ${NB_USER} 8 | 9 | ## run any install.R script we find 10 | RUN if [ -f install.R ]; then R --quiet -f install.R; fi 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RStudio in Binder using a Dockerfile 2 | 3 | [![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/v2/gh/binder-examples/dockerfile-rstudio/master) 4 | 5 | ***NOTE**: RStudio/R support is now supported natively in Binder. See the 6 | [R example repository](https://github.com/binder-examples/r) for how to 7 | create an RStudio session using `runtime.txt`.* 8 | 9 | This is a proof-of-concept to deploy a Binder that exposes the 10 | RStudio UI instead of a Jupyter Notebook. It also installs 11 | several packages from the tidyverse, and includes a demo 12 | script to show off functionality. 13 | 14 | To start your RStudio session, click on "new" in the top right, 15 | and at the bottom will be `RStudio Session`. 16 | Click that and your RStudio session will begin momentarily! 17 | 18 | See `instructions.ipynb` for more details. 19 | 20 | *Special thanks to Ryan Lovett (@ryanlovett) for figuring out 21 | RStudio support with JupyterHub* 22 | -------------------------------------------------------------------------------- /index.R: -------------------------------------------------------------------------------- 1 | # ggplot2 examples 2 | library(ggplot2) 3 | 4 | # create factors with value labels 5 | mtcars$gear <- factor(mtcars$gear,levels=c(3,4,5), 6 | labels=c("3gears","4gears","5gears")) 7 | mtcars$am <- factor(mtcars$am,levels=c(0,1), 8 | labels=c("Automatic","Manual")) 9 | mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8), 10 | labels=c("4cyl","6cyl","8cyl")) 11 | 12 | # Kernel density plots for mpg 13 | # grouped by number of gears (indicated by color) 14 | qplot(mpg, data=mtcars, geom="density", fill=gear, alpha=I(.5), 15 | main="Distribution of Gas Milage", xlab="Miles Per Gallon", 16 | ylab="Density") 17 | 18 | # Scatterplot of mpg vs. hp for each combination of gears and cylinders 19 | # in each facet, transmittion type is represented by shape and color 20 | qplot(hp, mpg, data=mtcars, shape=am, color=am, 21 | facets=gear~cyl, size=I(3), 22 | xlab="Horsepower", ylab="Miles per Gallon") 23 | 24 | # Separate regressions of mpg on weight for each number of cylinders 25 | qplot(wt, mpg, data=mtcars, geom=c("point", "smooth"), 26 | method="lm", formula=y~x, color=cyl, 27 | main="Regression of MPG on Weight", 28 | xlab="Weight", ylab="Miles per Gallon") 29 | 30 | # Boxplots of mpg by number of gears 31 | # observations (points) are overlayed and jittered 32 | qplot(gear, mpg, data=mtcars, geom=c("boxplot", "jitter"), 33 | fill=gear, main="Mileage by Gear Number", 34 | xlab="", ylab="Miles per Gallon") 35 | -------------------------------------------------------------------------------- /instructions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# RStudio Demo" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "While you can use R in this notebook, this Binder is meant to show an RStudio Demo.\n", 15 | "\n", 16 | "In the dashboard click on \"New\" > \"RStudio Session\".\n", 17 | "\n", 18 | "![rstudio_ui.png](rstudio_ui.png)" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.6.2" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 2 43 | } 44 | -------------------------------------------------------------------------------- /rstudio_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binder-examples/dockerfile-rstudio/249838f2ac7e018fdf560b930780cb4770faf049/rstudio_ui.png --------------------------------------------------------------------------------