It is important to keep R and RStudio up-to-date. While it might be the case that you won’t have any issues with older versions, as packages are updated, you may receive strange errors. Follow steps 1 to 5 to also upgrade R and RStudio to new versions.

1. Download the appropriate version of R

Click on R for Windows. You will see text at the very top of the page saying “Download R for Windows”. Click on this link, which will bring up the dialog to save the file.

2. Install R

Double click on the downloaded R package (EXE file) in the folder you specified. An example is shown below.

Downloaded R

Follow the installation instructions. You do not need to open R after the completed installation. RStudio will automatically do that after it is installed and opened.

3. Download RStudio

RStudio is currently available for Windows Vista/7/8/10. Click on RStudio Download Links. Click on the appropriate Windows file under Installers for Supported Platforms. This will again bring up the save file dialog.

4. Install RStudio

After your download has completed, find your version of RStudio in the folder you specified.

Downloaded RStudio

Double click on the downloaded RStudio EXE file and follow the installation instructions.

5. Download MiKTeX

MiKTeX installs many of the things needed to use TeX for typesetting. Click on this link to download MiKTeX: http://miktex.org/download. You’ll want to download the Recommended Download listed first on the page.

6. Install MiKTeX

Find your version of MiKTeX in the folder you specified.

Downloaded MiKTeX

Double click on the MiKTeX file and follow the installation instructions. This will probably take 10-15 minutes to complete. You do not need to open anything after MiKTeX is finished installing.

7. Install useful R packages in RStudio

Download the file available at startup_packages.R. (Right click on the link and save the file to a location instead of just left-clicking on the link.) This is a text (script) file containing R commands that you will run. Double click on this downloaded file in your specified directory. This will open the file in RStudio. Shown below is only the top left pane of the four panes in RStudio and an example script file. (Note the text in the photo may differ slightly compared to the actual content of startup_packages.R).

R Script Open

You now want to run all of this code to install the packages listed at the top. To do this, click on the Source button in the upper right of the top left pane (the one that has this code in it).

You should see some red text appear in the Console tab of the bottom left panel in RStudio. The code has downloaded the packages specified and you can now use them in your code as needed.

8. Test installation

To check that R, RStudio, and TeX have been installed correctly, we will create a sample R Markdown document. These types of documents will give you the ability to nicely document your code, include your code, and also the output that your code produces.

Select File > New File > R Markdown from the RStudio taskbar menu.

Create R Markdown

In the resulting screen, select Document on the left and select PDF as the Default Output Format. (This will check that MiKTeX was appropriately installed. You can also create HTML or Word documents by choosing the appropriate output format here. You can also change your mind later and create any of (or all of) the three of these formats if you so choose.)

R Markdown Document

This creates a basic R Markdown file with some hints as to how to do a few things using R Markdown. To see what the resulting output looks like based on this code, click on the Knit PDF button near the top of the pane.

Note: You may be prompted to install some extra LaTeX/R packages at this point or at a nearby point. Go ahead and say “Yes.” You’ll likely only need to do this the very first time.

Knit PDF

After giving the resulting PDF a name, you should obtain a PDF similar to the one shown below. (Note that you may be prompted to install some additional LaTeX packages on this first knitting that will take a few minutes.) The resulting PDF will be stored in the same directory as the Rmd (R Markdown file) you just created.

PDF output

Questions

Contact Kristin Bott, associate director of instructional technology, at kbott@reed.edu.