How to Get Organized with RStudio Projects and Git
Use RStudio Projects and Git to organize your data science projects
Would you like to better organize your data science projects following a simple and consistant workflow?
In my new YouTube video, I show you how to use RStudio Projects and Git version control to follow a consistant file structure and track all the changes in your code.
You will learn how to:
use RStudio projects and connect them to Git and GitHub (the easy way);
use RStudio Git panel view to commit, push and pull files with 1 click;
see an example of a data science project file structure.
Watch the video now:
Data science projects can quickly become chaotic without proper organization and version control. In this tutorial, you’ll learn how to use RStudio Projects and Git to maintain clean, organized, and portable data science workflows.
The Problem: Disorganized Project Folders
Many data scientists end up with folders that look like this:
analysis.R
new-analysis.R
new-analysis-version2.R
ideas-from-document.R
Mixed files from different projects in the same directory
This disorganized approach leads to confusion, lost work, and difficulty collaborating with others. Let’s fix this using RStudio Projects and Git version control.
Creating Your First RStudio Project
Step 1: Start a New Project
Click on the New Project button in the top-right corner of RStudio
You’ll see three options:
New Directory: Creates a new folder
Existing Directory: Uses an existing folder
Version Control: Connects to Git (we’ll cover this later)
Step 2: Choose Project Type
Select New Directory, then choose from various project templates: - Empty new project (recommended for beginners) - R package - Shiny application - Quarto projects - And other specialized templates
Step 3: Configure Your Project
Directory name: This becomes your project folder name (e.g., “organized”)
Subdirectory: Choose where to save your project
Pro tip: Create a dedicated folder for all your data science projects
Consider syncing with cloud storage (OneDrive, Google Drive, etc.)
Optional settings:
Git repository (we’ll set this up separately)
renv
for package management (recommended for advanced users)
Click Create Project to finish setup.
Understanding Project Benefits
Automatic Working Directory
RStudio Projects automatically set your working directory to the project root. This means: