Introduction to R and Rstudio

Session - Projects

Zoë Turner

Projects

Alison Horst's cartoons of three cubes, there is a setwd looking cross having broken an arm and a leg, the RProj with a skateboard and a small, concentrating purple cube with a helmet doing tricks on its skateboard

Working Directory

If you tell R/R Studio to look for a file, or save a plot, it will (by default) look in a place called the working directory (wd)

Screenshot of the tabs `Console/Terminal` and Jobs in RStudio and underneath the location of the workshop at ~

Change overall default Working Directory

Often defaults to the Documents folder but can be changed in Tools/Global Options

Screenshot of the Tools/Global Options with the Default working directory box highlighted.

Bookmarks

A Project can make it easier to find tell your session where to get files from and where to save them but, like bookmarks, you can:

  • share this location with others
  • move between projects easily

Project menu

Step 1

Screenshot of the specific project menu from the top right area of RStudio

Step 2

Screenshot of the project wizard when new Project... selected

Project Type and Name wizards

Step 3

Screenshot of the project type list starting with New Project but includes R Package and Shiny Application

Step 4

Screenshot of the project name wizard where the location can also be changed

Have a go! Not for the RStudio Cloud

  1. Create a project in an existing folder using the Project menu.
  2. Note the name of the .Rproj file that is generated automatically.
  3. Create a new project, this time choosing the selection Shiny Application. What files are created?
  4. Using the Project menu move between the two projects.

Extra: Delete one of the .Rproj files and then try to select it from the menu. What happens?

Browsing in RStudio

Click the three dot icon in the bottom right quadrant, Files tab:

A screenshot of the Files tab with the three dot button highlighted, the words Click to open and explorer type browser is on the image.

Getting back to the working directory

First way:

Click the grey arrow next to the file pathway ~/ in the Console

Screenshot of the working directory name and grey arrow found in the Console.

Second way:

Once a project has been created an R hex logo appears in the Files tab next to the three dots

A screenshot of the Files tab with the R hex icon next to the three dots highlighted.

End session