Author: Tiffany Timbers
This repository is a demonstration of how to use Jupyter and nbgrader for autograding R assignments.
Talk slides: ttimbers.github.io/jupyter-nbgrader-r/slides/jupyter-nbgrader-r.html
There are two different ways you can interact with this demo:
-
SSC 2021 Workshop participants only, on the day of the workshop can login to this JupyterHub using provided username and password: dsci-100-instructor.stat.ubc.ca
-
See an instructor-like experience via a local install of all the required software
We provide install instructions for the 3 major operating systems:
nbgrader is a Python program, thus you will need to install it even if you plan to run R in Jupyter. Luckily, Anaconda, a popular Python distribution comes with Jupyter as well! When you install Anaconda, you need Python 3 to run nbgrader, not Python 2, so please choose the Anaconda version that includes Python 3.9 (or higher)
Head to https://www.anaconda.com/download/#macos and download the Anaconda version for Mac OS with Python 3.9 (or higher). Follow the instructions on that page to run the installer.
To use R with Jupyter, you will need to install R and the IRkernel. To install R, go to https://cran.r-project.org/bin/macosx/ and download the latest version of R for Mac. Open the file and follow the installer instructions.
To install the IR kernel open R and type the following commands into the console:
install.packages(c('IRkernel'))
Next, open terminal and type the following:
R -e "IRkernel::installspec()"
Open the terminal and type the following:
conda install -c conda-forge nbgrader
jupyter nbextension install --sys-prefix --py nbgrader --overwrite
jupyter nbextension enable --sys-prefix --py nbgrader
jupyter serverextension enable --sys-prefix --py nbgrader
nbgrader is a Python program, thus you will need to install it even if you plan to run R in Jupyter. Luckily, Anaconda, a popular Python distribution comes with Jupyter as well! When you install Anaconda, you need Python 3 to run nbgrader, not Python 2, so please choose the Anaconda version that includes Python 3.7
Head to https://www.anaconda.com/download/#windows and download the Anaconda version for Windows with Python 3.7. Follow the instructions on that page to run the installer.
To use R with Jupyter, you will need to install R and the IRkernel. To install R, go to https://cran.r-project.org/bin/windows/base/ and download the latest version of R for Windows. Open the file and follow the installer instructions. Open the file and follow the installer instructions.
To install the IR kernel open R and type the following commands into the console:
install.packages(c('IRkernel'))
IRkernel::installspec()
Open CMD and type the following:
conda install -c conda-forge nbgrader
jupyter nbextension install --sys-prefix --py nbgrader --overwrite
jupyter nbextension enable --sys-prefix --py nbgrader
jupyter serverextension enable --sys-prefix --py nbgrader
nbgrader is a Python program, thus you will need to install it even if you plan to run R in Jupyter. Luckily, Anaconda, a popular Python distribution comes with Jupyter as well! When you install Anaconda, you need Python 3 to run nbgrader, not Python 2, so please choose the Anaconda version that includes Python 3.7
Head to https://www.anaconda.com/download/#linux and download the Anaconda version for Linux with Python 3.7 (make sure the linux tab is selected). Once the download is finished, open Terminal and execute the following commands:
bash path/to/the/file
For example,
bash Downloads/Anaconda3-2021.05-Linux-x86_64.sh
The instructions for the installation will then appear: (1) press Enter; (2) once the licence agreement shows, you can keep pressing enter to go through the whole document, or press Q to quit; (3) Type yes
to accept the licence agreement; (4) you can accept the default installation location (just press Enter once again); (5) Type yes
once again to accept the installer to run conda init
.
To use R with Jupyter, you will need to install R and the IRkernel. To install R, follow the instructions below:
Type the following in the Terminal to add the key ID for the CRAN network:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Type sudo apt-add-repository
in Terminal followed by the corresponding line for your version:
- for Ubuntu 20.04 (Focal) add:
'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
- for Ubuntu 19.04 (Disco) add:
'deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/'
- for Ubuntu 18.04.1 (Bionic Beaver) add:
'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
- for Ubuntu 17.10.1 (Artful Aardvark) add:
'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
- for Ubuntu 16.04.4 (Xenial Xerus) add:
'deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/'
- for Ubuntu 14.04.5 (Trusty Tahr) add:
'deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/'
For example, for Ubuntu 20.04 (Focal):
sudo apt-add-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'`
Then, update the repository:
sudo apt-get update
Next, install the following packages:
sudo apt-get install curl libssl-dev libcurl4-openssl-dev libpq-dev libxml2-dev r-base
To install the IR kernel open R and type the following commands into the console:
install.packages(c('IRkernel'))
IRkernel::installspec()
Open the terminal and type the following:
conda install -c conda-forge nbgrader
jupyter nbextension install --sys-prefix --py nbgrader --overwrite
jupyter nbextension enable --sys-prefix --py nbgrader
jupyter serverextension enable --sys-prefix --py nbgrader
- slides and example derived from a talk given by Mine Çetinkaya-Rundel (University of Edinburgh, Duke University, RStudio) & myself at ECOTS 2020: bit.ly/feed-me-back
License: CC-BY 4.0 International