A starter template for R-based data analysis projects, designed for the Aigora course on AI-assisted coding for sensory and consumer scientists.
- Click Use this template on GitHub to create your own repo.
- Clone your new repo and open the
.Rprojfile in RStudio. - Rename
generic-repo.Rprojto match your project name (e.g.,my-project.Rproj). - Update this README — replace the title and description above with your own.
- Install any packages you need via the R console (
install.packages("package_name")), then addlibrary()calls toscripts/supporting/load_libraries.R.
.
├── CLAUDE.md # Conventions for AI coding assistants
├── background/ # Reference materials, papers, notes
├── input/
│ ├── raw_data/ # Raw data files (not tracked by git)
│ └── templates/ # Report or output templates
├── output/ # Generated output (not tracked by git)
├── rmarkdown/ # R Markdown documents
└── scripts/
├── main_script.R # Main analysis script
└── supporting/
├── load_constants.R # Project constants and directory paths
├── load_functions.R # Custom functions
└── load_libraries.R # Package loading
scripts/main_script.R is the entry point. It sources three supporting scripts in order:
load_libraries.R— Addlibrary()calls here for each package your project uses. A commented-outlibrary(tidyverse)is included as a starting point.load_constants.R— Defines directory paths (input_dir,output_dir) and any project-wide constants. Add your own as needed.load_functions.R— Define custom helper functions here to keepmain_script.Rclean.
Add your analysis code to main_script.R after the source() calls, or create additional scripts as your project grows.
Data files (.csv, .xlsx, .rds, .sav, .sas7bdat, etc.) are git-ignored by default to prevent accidental commits of large or sensitive data.
- Place raw, unmodified data in
input/raw_data/and keep it unchanged throughout your analysis. - If you need to track a specific data file in git, use:
git add -f input/raw_data/myfile.csv - Generated output goes in
output/, which is also git-ignored. - Document how collaborators can obtain your data (e.g., shared drive, download link) in this README.
This template includes a CLAUDE.md file that tells AI coding assistants (like Claude Code) about the project structure and conventions. When you use an AI assistant in this repo, it will automatically read CLAUDE.md to understand how the project is organized. Update it as your project evolves.
- Use
file.path()to build paths (e.g.,file.path(input_dir, "raw_data", "myfile.csv")) instead of hardcoding/or\— this keeps your code portable across operating systems. - Keep
main_script.Rhigh-level and readable. Move complex logic into functions inload_functions.R. - Commit early and often. Small, frequent commits make it easier to track changes and recover from mistakes.