Tooling
Here is an overview of all the tools used in this template - including some helpful information on how to apply them - making your R code both nicer and more robust 😉.
Managing R Installations
It's recommended to use rig - the R Installation Manager - for managing R installations.
Tools
This template uses the following tools:
- rig: R installation manager.
- renv: R project and dependency management.
- Air: R formatter and language server.
- Jarl: R linter.
- testthat: R testing suit.
- GitHub Actions: Used for running the above automatically.
Helpful Commands
- rig:
- Install a specific R version, e.g.
4.6.1:bashrig add 4.6.1 - Set a default R version, e.g.
4.6.1:bashrig default 4.6.1
- Install a specific R version, e.g.
- renv:
- Restore an R environment:bashor
Rscript -e "renv::restore()"rrenv::restore() - Snapshot an R environment:bashor
Rscript -e "renv::snapshot()"rrenv::snapshot() - Install a package:bashor
Rscript -e "renv::install('pkg')"rrenv::install("pkg") - Install a package from Bioconductor:bashor
Rscript -e "renv::install('bioc::pkg')"rrenv::install("bioc::pkg")
- Restore an R environment:
- Air:
- Format files:bash
air format - Alternatively, setup
aireditor integration as described here. - Check if files are properly formatted:bash
air format --check
- Format files:
- Jarl:
- Lint with
jarl:bashjarl check .
- Lint with
- testthat:
- Test with
testthat:bashRscript -e "source('tests/testthat.R')"
- Test with
- Run application:
- CLI mode (example for this application):bash
Rscript run.R -f data/characters.csv - Shiny mode (example for this application):bash
Rscript run.R -s
- CLI mode (example for this application):
