10.3 Set the “working directory” (“WD”) in RStudio
We will now take the data we saved as a .csv file and load it into R. This can be tricky. First we need to tell R exactly where the file is by setting the working directory.
Follow these steps:
- Click on “Session” on the main menu
- on the menu: “File, Edit, Code, View, Plots, Session, …”
- Click on “Set working directory”
- Select “Choose Directory”
- Select your computer’s Documents folder or wherever else you chose to save the file.
- Select the directory & click “Open”
- Note that the command “setwd()” shows up in the console followed by the location of the directory you selected
You can set your working directory to be anywhere on the computer. It is essential to make sure that the csv file you want to load into R is in your working directory.
Depending on the location you chose you might just see “~/” or some other shorthand.