Q&A 1 How do you create a project directory ready for analysis?

1.1 Explanation

Before working with data, it’s important to set up a clean and organized project directory. A consistent folder structure helps you manage scripts, datasets, and outputs across both Python and R — making your work easier to follow and share.

In this guide, we’ll create a root directory called general-data-science with four folders:

  • data/ – for datasets
  • scripts/ – for code files
  • images/ – for plots and charts
  • library/ – for reusable functions

Example Folder Structure:

general-data-science/
├── data/
├── scripts/
├── images/
└── library/

1.2 Bash (Terminal)

You can create the entire structure using this single command:

mkdir -p general-data-science/{data,scripts,images,library}
cd general-data-science

1.3 Python Code

You can also create the same folder structure in Python:

import os

folders = ["data", "scripts", "images", "library"]
root = "general-data-science"

os.makedirs(root, exist_ok=True)
for folder in folders:
    os.makedirs(os.path.join(root, folder), exist_ok=True)

print(f"Created '{root}' project folder with subdirectories.")

1.4 R Code

Here’s how to do it in R:

folders <- c("data", "scripts", "images", "library")
root <- "general-data-science"

if (!dir.exists(root)) dir.create(root)
for (folder in folders) {
  dir.create(file.path(root, folder), showWarnings = FALSE)
}

cat("Created", root, "project folder with subdirectories.\n")