POLS 3000: Principles of Programming

Installing and Acesssing RProgramming Tutorials

Author

Professor Knuppe

Published

January 14, 2023

Introduction to Programming Tutorials

Our textbook, Quantitative Social Science: An Introduction in Tidyverse by Kosuke Imai, includes a series of programming tutorials to help you practice the new code introduced in each chapter.

These tutorials were developed by Harvard University’s Matthew Blackwell, but are largely adapted from the original swirl course, qss-swirl.

Weekly, at-home tutorials provide you with “low stakes” practice, helping to introduce new comments. The goal is to provide you with exposure to new code and concepts before you have to implement them in your problem sets and take-home exams.

NOTE: Students will complete one tutorial each week, graded as pass/fail (10 points).

Installing the Programming Tutorials in RStudio

To install the tutorials, first install the qss, learnr, and gradethis packages:

remotes::install_github("kosukeimai/qss-package", build_vignettes = TRUE)
remotes::install_github("rstudio/learnr")
remotes::install_github("rstudio-education/gradethis")
remotes::install_github("mattblackwell/qsslearnr")

Then you can start the tutorials in one of two ways. First, in RStudio 1.3 or later, you will find the QSS tutorials listed in the “Tutorial” tab in the top-right pane (by default). Find a tutorial and click “Run Tutorial” to get started. Second, you can run any tutorial from the R console by typing the following line:

learnr::run_tutorial("00-intro", package = "qsslearnr")

This should bring up a tutorial in your default web browser. You can see the full list of tutorials by running:

learnr::run_tutorial(package = "qsslearnr")

The interface to the tutorials will look like this:

Although there are 11 baseR tutorials in total, only 7 (00 - 06) of such tutorials are in tidyverse since all of the rest (07 - 10) contain conceptual questions.

Submitting Tutorial Reports to Canvas

At the end of each tutorial, you can download a submission report that describe what questions and exercises you attempted. You can then upload the PDFs with your last names (e.g., knuppe-tutorial-1.pdf) to the appropriate assignment on Canvas.

In the event that the PDF submission feature on RStudio does not work, you can save a screen shot of the completed tutorial (On a Mac: Shift, Command, and 4) and then upload the .png or .jpeg filed to Canvas.

The PDF report document will look like this:

The final step is to upload the PDF report to the appropriate assignment on Canvas:

FAQs

What if I receive an error about pdflatex and the submission report doesn’t download?

To generate the reports, you need something called LaTeX. You should have installed this with Problem Set 0, but the following command will install it:

install.packages('tinytex')
tinytex::install_tinytex()  # install TinyTeX

What if I don’t see a Tutorial tab in RStudio?

Make sure that you have RStudio version 1.3 or higher installed on your computer. On a Mac, you can check the version by going to the top left of the menu bar (next to the Apple logo) and clicking on “RStudio” then “About RStudio”. On a Windows PC, you can find the same item under File > About.

What if my submission report misses some of my attempts?

The submission report isn’t perfect and will sometimes say you didn’t attempt a question when you actually did. We do not grade strictly on this and are mostly looking for a confirmation that you made a good-faith effort to complete the tutorial.