Installing R, RStudio, R Markdown, Latex

Supplement to pol346

Team 346 (Department of Politics, Princeton University)

For POL346, we require students shift away from word processors like Microsoft Word and use a workflow that involves R and a formatting language called R Markdown (as is done in POL345). The two languages are glued together with another language called knitr. Certain kinds of advanced typography, like formulas, rely on yet another language called Latex. Installing and configuring all of this will impose a modest learning curve at the start but will make life much easier down the road.

The basic advantage of R + R Markdown + knitr + Latex is that you can easily braid together your prose, R code, formulas and R output (e.g., plots and tables) in a single document. This not only saves time and makes life easier by reducing the number of files that need to be managed, it also helps with creating better research such as when you write JPs or Senior Theses (we’ll discuss this more in class).

To get set up with R + R Markdown + knitr + Latex, please do the following before precept:

Install software and packages

If necessary, install LaTeX


Alternate ways to install LaTeX

Test your installation


For students who took POL345:


  1. Hit command-space, type Terminal to open the Terminal app

  2. Copy and paste the following text in to the command line prompt in the Terminal app and hit return

sudo chown -R `whoami`:admin /usr/local/bin
  1. Copy and paste the following text in the Terminal app and hit return.
~/Library/TinyTeX/bin/x86_64-darwin/tlmgr path add
  1. Try to run the following commands in R:
tinytex::install_tinytex(force = TRUE)


  1. Attempt to uninstall MikTek
  1. Try to run the following commands in R
tinytex::install_tinytex(force = TRUE)