This is an attempt to make an R project template, that is not an R package, and that uses some of the recent tools that have been created in the R ecosystem. The template is inspired by the python-project-template by Gemma Danks.
The project features rv for project management and packaging, jarl for linting, and air for formatting, justfile, testthat testing, quarto documentation created with quartrify, .editorconfig, .devcontainer, GitHub Actions CI, and automated semantic releases.
While the template can help you start writing code immediately without having to spend time deciding what tools or conventions to use, the tools and conventions that it introduces are not the default way of doing things in the R world, and there is a question mark if they get adopted in the future or not.
- π± Create a New Repository on GitHub
- Click "Use this template".
- Choose βCreate a new repositoryβ.
- Pick a name for your new project (for example,
my-awesome-package). - Clone your new repo locally
- π‘ Customise the repository
- Rename your package directory
cd src; mv package_name my_package - Update rproject.toml with your package name, author, and description, and preferred repository.
- Update all references to package_name in:
- package_name/tests/
- docs/
- release-please-config.json
- GitHub Actions workflow
- This README (including badge links)
- Update the
"package-name"field in release-please-config.json with your package name for automatically bumping the version number in uv.lock (see release-please issue #2561). - Customise this README with a description of your project and planned features.
- Clear the CHANGELOG.
- Enable automated releases by permitting GitHub Actions to open PRs (Settings -> Actions -> Workflow permissions) and add an initial commit hash to bootstrap the release-please in .release-please-manifest.json.
- Enable publishing to GitHub Pages (Settings -> Pages).
- Rename your package directory
- Modular project directory structure using box.
- README template with badges.
- Packaging and dependency management via rv: rproject.toml.
- Linting via Jarl.
- Formatting via Air.
- Testing framework using testthat.
- Pre-commit hooks (linting and formatting).
- CI using GitHub Actions: .github/workflows/ci.yml.
- Docs generated with Quartrify and deployed to
gh-pagesbranch via GitHub action: .github/workflows/generate-docs.yml. - Templates for GitHub issues: bug report (01-bug.yml) and feature request (02-feature.yml).
- Template for GitHub pull request: .github/pull_request_template.md.
- Template for documenting architectural decisions: docs/architecture/adr/template.md.
- ADR to explain the rationale for using ADRs: docs/architecture/adr/001-use-architectural-decision-records.md.
- Release automation via GitHub action from release-please: .github/release-please-config.json.
- Citation metadata, automatically updated for each new release: CITATION.cff.
- EditorConfig configuration for consistent coding style across editors: .editorconfig.
- Test coverage cannot be registered with codecov because it seems the R package
covrdoes not work in this type of project structure. pkgdowncannot be used for documentation for the same reason as above.devtools::check()does not work because it expects a package structure with aDESCRIPTIONfile and anR/directory for source code, which this template does not have.
A Dockerfile and configuration in ./.devcontainer can be used in VSCode or GitHub Codespaces to work in a pre-configured development environment. It uses a Python 3.14 base image and installs uv, just and all Python dependencies.
To open the project in the container VSCode, you will need to add the Dev Containers extension and download Docker (or Podman -- and configure VSCode to use podman instead of Docker) -- see the VSCode tutorial on devcontainers for more details on using devcontainers. Then run:
Dev Containers: Reopen in Container- Install rv
- optional, if you want to use shortcut commands, install just
- optional, if you want to use pre-commit hooks, install uv
- Clone and install the project using rv:
git clone https://github.com/gemmadanks/r-project-template
cd r-project-template
rv sync- Install just.
- Install pre-commit hooks (only needs to be done once)
Several common tasks have been added as recipes to a justfile in the root of the repository:
default # Default recipe (shown when running plain `just`)
docs-build # Build docs (Quartrify)
format # Format (Air format)
install # Install dependencies (create/update virtualenv)
lint # Lint (Jarl check)
test # Run testthat
update # Upgrade packages to the latest versions available- Generated with Quartrify. Probably a lot can be improved here.
Managed by release-please: (conventional commits drive semantic versioning and an autogenerated CHANGELOG). - Configuration: .github/release-please-config.json - Version source: rproject.toml
.
βββ src/
β βββ package_name/ # Source package
β βββ __init__.r
β βββ hello.py # Example module (replace with real code)
| βββ __tests__/ # Test suite for the example module
| βββ __init__.r
| βββ helper-module.r
| βββ test_hello.R
βββ data-raw/ # Raw data used in the project (if applicable)
βββ docs/ # Generated quarto documentation
β βββ __init__.qmd
β βββ index.qmd
β βββ hello.qmd
β βββ html/* # Generated HTML docs (deployed to GitHub Pages)
βββ notebooks/ # Quarto notebooks
β βββ demo.qmd
βββ .github/
β βββ workflows/
β β βββ ci.yml # Lint / test / build
β β βββ generate-docs.yml # Generate and deploy docs
β β βββ release-please.yml # Automated releases
| | βββ update-citaton-date-released.yml # Update date-released in CITATION.cff on new release
βββ .devcontainer/ # Dev container configuration
β βββ devcontainer.json
β βββ Dockerfile
βββ rproject.toml # Project metadata + dependencies (rv)
βββ rv.lock # Locked dependency versions (rv)
βββ README.md # Project overview (you are here)
βββ CITATION.cff # Citation metadata
βββ LICENSE # License
βββ NEWS.md # Generated by release-please (post-release)
βββ .pre-commit-config.yaml # Pre-commit hooks configuration (uv)
βββ .release-please-manifest.json # Release-please state
βββ release-please-config.json # Release-please configuration
βββ justfile # justfile containing recipes for common tasks
βββ .editorconfig # Ensures consistent code style across editors
βββ .gitignoreNote that while it is common practice to keep the config files at the root of the
repository, and this is what I recommend, it is possible to customise the
location of some of them if you prefer
(e.g. the path to release-please-config.json [can be specified in the
release-please.yml file for the GitHub action]
(https://github.com/googleapis/release-please-action?tab=readme-ov-file#advanced-release-configuration).
Use conventional commit messages (feat:, fix:, docs:, etc.). Ensure:
- Lint & format clean
- Tests pass
- Docs build without warnings
- ADR drafted for architecturally significant changes
Suggestions and improvements to this template are very welcome β feel free to open an issue or pull request if you spot something that could be refined, added or removed.
If used in research, cite via CITATION.cff.
BSD-3-Clause β see LICENSE.
Happy coding! π