Skip to content

aigorahub/generic-r-repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generic R Project Template

A starter template for R-based data analysis projects, designed for the Aigora course on AI-assisted coding for sensory and consumer scientists.

Getting Started

  1. Click Use this template on GitHub to create your own repo.
  2. Clone your new repo and open the .Rproj file in RStudio.
  3. Rename generic-repo.Rproj to match your project name (e.g., my-project.Rproj).
  4. Update this README — replace the title and description above with your own.
  5. Install any packages you need via the R console (install.packages("package_name")), then add library() calls to scripts/supporting/load_libraries.R.

Project Structure

.
├── 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

How It Works

scripts/main_script.R is the entry point. It sources three supporting scripts in order:

  1. load_libraries.R — Add library() calls here for each package your project uses. A commented-out library(tidyverse) is included as a starting point.
  2. load_constants.R — Defines directory paths (input_dir, output_dir) and any project-wide constants. Add your own as needed.
  3. load_functions.R — Define custom helper functions here to keep main_script.R clean.

Add your analysis code to main_script.R after the source() calls, or create additional scripts as your project grows.

Working with Data

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.

Working with AI Assistants

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.

Tips

  • 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.R high-level and readable. Move complex logic into functions in load_functions.R.
  • Commit early and often. Small, frequent commits make it easier to track changes and recover from mistakes.

About

Generic template for R-based data analysis projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages