FAQ

How do I download R and R Studio?

R is freely maintained by an international team of developers and is available through The Comprehensive R Archive Network. Follow the instructions below to download R. If you are using an older computer or iPad, skip to 1.4 Using Posit Cloud for R.

Downloading R

  • Go to The Comprehensive R Archive Network webpage:
  • To install R on Windows, click the “Download R for Windows” link.
  • To install R on a Mac, click the “Download R for Mac” link.

Downloading RStudio

One way to picture what RStudio does is to compare it to Microsoft Word, a software application that allows us to write documents. RStudio, instead of being a platform to write text, helps us write in the coding language R. Follow the instructions below to download RStudio.

  • Go to the Posit RStudio Desktop page.
  • To install for Mac:
    • Scroll to the button that says “Install R on a Mac,” and click the “Download R for Mac OS 13+” link.
    • If you’re using an older version, click the “Previous Versions” link to find a version that works with your computer.
  • To install for Windows:
    • Scroll to the button that says “Install R on Windows 10/11,” and click the link to download.

Using Posit Cloud for R

Posit Cloud is the most common cloud service used when working with RStudio and is free up to a point.

https://posit.cloud/

  • First, choose the “Cloud Free” plan.
  • Second, follow the Posit Cloud instructions to log in.
  • Third, go to the “Tutorial” tab in the upper right corner, scroll to the bottom, and select “Getting Started with Tutorials,” then press the “Start Tutorial” button.
  • You will work in a singular RProject space for the majority of the class.

What is a quarto file?

If you have ever used an Rmarkdown file before, Quarto the next generation version of this! Quarto files allow you to make pdf, word documents, presentations, and even websites. In this course you will be making a word document using a provided quarto file for your lab submissions.

What is a file path?

A file path is a unique “address” that tells your computer where to find certain information. For example, if you are looking for a document called Homework1.qmd in a folder on you desktop labeled POL 051, then the file path to find this document would be:

~/desktop/POL 051/Homework1.qmd

Mac File Path Setup

Mac Books and Windows computer have different starts to their file paths, here is a macbook’s setup:

/Users/John/desktop/POL 051/Homework1.qmd

Windows File Path Setup

C:/Users/John/desktop/POL 051/Homework1.qmd

What is a working directory?

The working directory is the folder in your computer that you have set to save files to during your working session on R. Essentially, you are telling your computer to save any new documents or updates to this specific folder, rather than maybe your downloads folder.

It is important to keep all the files associated with a given project, such as data, scripts, analytical results, and figures, together. To do this we need to make a working directory.

To create a new working directory in RStudio:

  1. Use File → New Project or use the New Project button (available on the Projects toolbar in the top right corner or on the global toolbar at the top left corner).
  2. This will open the “New Project Wizard” popup.
  3. Click “New Directory”.

To set the working directory, there are two possible ways, using code or using RStudio directly:

Option 1: Using R Code

# Set working directory (replace this with your own)

# Mac Users
setwd("/Users/yourname/Desktop/filename/filename")
# Windows Users
setwd("C:/Users/YourName/Documents/MyFolder")

Option 2: Using RStudio Interface

  1. On the top of the RStudio menu, click on Session.

  2. Click Set Working Directory.

  3. Then click To Source File Location.

To check if the working directory is set correctly, use the following code:

# Returns the filepath of the current working directory
getwd()

If you feel like this still ⤸

PLEASE PLEASE PLEASE come to office hours or email me!