10 Best Practices for Structuring R Programming Projects
Practical habits for organizing R projects, managing packages, and collaborating effectively using version control.
YouTube · Susan B. · 10 March 2026 Watch on YouTube
Tried this idea? Show how yours turned out.
I made thisHow to do it
What you need
- RStudio or Positron IDE
- {renv}
- {targets}
- Git
- README.md
- scripts/ and R/ folders
- data/ folder for raw and processed data
- Environment variables (.Renviron)
Step by step
- Install packages in the console, then load only the ones you need with library() in your script.
- Set up {renv} so the project's package versions are locked and reproducible.
- Use one consistent project structure with folders such as scripts/, R/, and data/.
- Add a README.md at the root of the project describing what it contains.
- Use {targets} to organize larger, multi-step analysis workflows.
- Reference files with relative paths instead of absolute paths.
- Keep sensitive values in environment variables rather than written into scripts.
- Track the project with Git and treat raw data as read-only, never overwriting it.
Tips
- Keeping raw data read-only and writing results elsewhere lets you rerun the whole analysis from the original files at any time.
- Because the environment and paths travel with the project, someone who clones it can reproduce your results on a different machine.
- Loading only the packages a script actually uses keeps things lean and makes the dependencies easy to read.
Written by Tagrazzi from the original's description and photo.
The title and summary are written by Tagrazzi; the video belongs to its creator and plays from YouTube.
Comments (0)
No comments yet. Be the first to comment.
Sign in to write a comment.