R Projects

Learn to create R projects using rstudioapi.

When working with R, we often work on a project over several days, weeks, or even months. That means we’ll be opening and closing the files occasionally and will need to reload from where we last left off.

Press + to interact
R projects keep our work organized
R projects keep our work organized

An R project is a convenient solution to that need. It bundles all the files and directories so that everything is contained in one coherent package. It keeps one set of work together while keeping it separate from other projects’ tasks. Leveraging projects is also the first step in setting up our work in R to work with Git and GitHub. This lesson will explore R projects and how to create and manage them.

What is an R project?

An R project is a directory on our computer where we store all the files related to a specific task. This directory contains our R scripts, data files, figures, and any other files associated with the project. The project is the root directory of our working directory structure. It’ll be located above the main folders such as scripts, inputs, outputs, etc. When we create an R project, we’re assigning our root directory for a task. We can add our usual subfolder structure within that root directory to keep things well-organized.

Working with R projects

There are two primary methods for creating a ...