logo

Crowdly

Using RStudio projects helps to keep each of your projects (classes, packages, c...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Using RStudio projects helps to keep each of your projects (classes, packages, consulting projects) self-contained and makes it easy to switch between them.

You can switch between projects in RStudio with the project selector:

When you select a project RStudio will switch your working directory to match the project directory, and restore any tabs that you had when you last worked on the project.

In the above screenshot, what is the absolute path for the current project?

Projects make it easy to share your work with others, but you need to be careful when programming with file paths to keep the project self-contained. File paths in projects should be ‘relative’, that means the path implicitly starts from the project folder and locates a file within the project.

Suppose your project is located in the ‘project’ folder in your Documents, and it contains these files:

## project

## +-- R

## | +-- model.R

## | \-- plots.R

## +-- data

## | \-- weather.csv

## +-- project.Rproj

## \-- report.Rmd

What is the relative file path that is appropriate for reading in your data?

library(readr)

my_data <- read_csv("

")

It is important to use relative paths in your projects (especially your assignments!) as otherwise your code probably won’t work with the people you share it with. The absolute path of the data.csv file on your computer might be: /home/MarieCurie/Documents/project/data/weather.csv. Suppose I share my project with Alan Turing who uses Windows and saves the project into their Downloads folder. The weather.csv data file is now at C:\Users\AlanTuring\Downloads\project\data\weather.csv, and so the code that tries to find it at /home/MarieCurie/Documents/project/data/weather.csv won’t work at all! Using a relative path will work wherever the project folder is saved.

More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!