18 Folder set-up

Written by Isaac Ehrlich and last updated on 7 October 2021.

18.1 Introduction

In this lesson, we will discuss how to set up folders for assignments and projects in R. As the folder structure revolves around an RStudio project, make sure you have gone through the RStudio project lesson as well.

18.1.1 Folder set-up motivation

Many assignments and analyses you complete will require multiple files, including data files, code, and written reports. To keep these organized, we recommend using a consistent folder structure system. This will make loading data into your R environment simpler, and will help keep your analyses organized.

18.2 Folder set-up

After creating a folder with an R Project, you will want to create additional sub-folders to keep your materials organized. Ideally, you will have very few files (if any) in the same folder as your R Project - they should instead be stored in sub-folders as in the image below.

Example Folder Set-Up

We recommend using the following sub-folders:

  • Data/Input folder: One of the folders you will want to create is the data folder. Here, you will want to keep the original and cleaned data files you use in your analysis.
  • Figure/Plot folder: Whether you are creating your own plots or using pictures and figures from another source, a dedicated figure folder will help you keep any images you may want to use organized.
  • Results/Output folder: If you create any new data sets or have output from your analysis, you will definitely want to keep track of the these. A results folder will help keep your output organized.
  • Code/Scripts folder: If you are completing an assignment in R, you will certainly have written code and scripts you want to save. Whether for cleaning data or running complex analysis, be sure to save these files to a folder containing all of your code.
  • Other/Miscellaneous folder (if necessary): On occasion you may find that you are using files that don’t quite fit into any of the other folders. Rather than have these files float around your R Project, you may want to create an additional other folder and put those files in.

18.3 Key takeaways

  • Sub-folders help keep your files and analysis organized.
  • You will typically want to include folders for data, figures, results, and code.
  • Remember these are just recommendations! Experiment and figure out what works best for you.

18.4 Exercises

18.5 Next steps

You’re well on your way to keeping an organized project! Next we’ll talk about how you can use comments to keep your code readable and organized!

18.6 Exercises

18.6.1 Question 1

18.6.2 Question 2

18.6.3 Question 3

18.6.4 Question 4

18.6.5 Question 5

18.6.6 Question 6

18.6.7 Question 7

18.6.8 Question 8

18.6.9 Question 9

18.6.10 Question 10