Skip to contents


rdev supports my personal workflow, including creation of both traditional R packages and R Analysis Packages (vignette("analysis-package-layout")), enforcing consistency across packages, and providing Continuous Integration/Continuous Delivery (CI/CD) automation. I use the tools in rdev to improve code quality, speed up development of R code, and publish results of analyses in R and Quarto Notebooks as HTML to make them accessible to non-R users.


My current R development environment uses Homebrew, rig, RStudio, GitHub, a collection of R packages including rdev, Visual Studio Code, and Vim.


I use Homebrew Bundle to install all software on my systems; my basic macOS working environment is published on GitHub in macos-env.

Installing R

rig supports installation of multiple versions of official R binaries, which I use for reproducibility. To install R using rig, first install rig:

brew tap r-lib/rig
brew install --cask rig

Then install desired versions of R. The following installs R 3.4 through 4.3 on Intel based macs (as of 2023-11-13):

rig install oldrel/6 --without-pak
rig install oldrel/5 --without-pak
rig install oldrel/4 --without-pak
rig install oldrel/3 --without-pak
rig install oldrel/2 --without-pak
rig install oldrel/1 --without-pak
rig install oldrel --without-pak
rig install release --without-pak
rig default release

I don’t use pak, which rig installs by default, as it is not yet fully supported by renv.

Development Tools

Well, obviously, I use RStudio. RStudio is the leading IDE for R development and integrates with many R packages, although it sometimes falls short; I use GitHub and the command line for Git, and occasionally Visual Studio Code (which has better support for markdown) and Vim (which is faster for some types of edits).

RStudio, the GitHub desktop client, and Visual Studio Code are easily installed using Homebrew:

brew install --cask rstudio
brew install --cask github
brew install --cask visual-studio-code

It is recommended to change the default settings for .RData in RStudio (in Options > General > Basic > Workspace):

  • Uncheck “Restore .Data into workspace at startup”
  • Set “Save workspace to .Data on exit” to “Never”

Vim is installed by default on macOS and most Unix-like systems.


Managing packages and environments are a challenge for most modern languages. Thankfully R doesn’t have the same level of challenge as python, or even ruby, managing packages available within a project is a best practice. I use renv for this purpose, and use renv to install and manage all packages in all of my projects.

The setup-r script from rdev installs a base set of packages needed to run rdev in the R User Library. A streamlined version of that script is included below.

# fix rig permissions
sudo chown -R `whoami`:admin /Library/Frameworks/R.framework/Versions/*/Resources/library

RVERSION=`Rscript -e 'cat(as.character(getRversion()[1,1:2]))'`
USERLIB="$HOME/Library/R/`uname -m`/${RVERSION}/library"
DEVPKG='c("renv", "styler", "lintr", "miniUI", "markdown", "rmarkdown", "devtools", "pkgdown", "available", "languageserver")'

if [ ! -d "${USERLIB}" ]
    mkdir -p "${USERLIB}"

echo "install.packages(${DEVPKG}, repos=\"\", lib=\"${USERLIB}\")" | R --no-save
echo "remotes::install_github(${GITPKG}, lib=\"${USERLIB}\")" | R --no-save

The chown command is needed to allow updating the base packages using the RStudio Packages “Update” function. I generally update packages in RStudio with no projects open before starting development, then update packages in projects using renv::update().

If you’re installing (development) versions of packages from GitHub, it is recommended to set up a personal access token using usethis::create_github_token() and adding it to your .Renviron as GITHUB_PAT= using usethis::edit_r_environ().

Further Reading

My workflow has been heavily influenced by the DevOps movement and the research of the DevOps Research and Assessment (DORA) team at Google started by Dr. Nicole Forsgren. Their research shows how technical and non-technical capabilities improve outcomes.

The functions included in rdev support many of the technical capabilities, including:

  • Code maintainability
  • Continuous delivery
  • Continuous integration
  • Deployment automation
  • Shifting left on security
  • Test automation
  • Trunk-based development
  • Version control

An outline of my SIRAcon 2022 talk, “Making R Work for You (With Automation)” is available on GitHub in siracon2022.