background picture with networks
🎁 Bonus #1

{renv} for better reproducibility

Ever had a colleague say, 'I've cloned your repo and tried running your code β€” it doesn't work on my computer'? πŸ™ˆ

The culprit is likely package version discrepancies. With renv, an R package, you can ensure everyone shares the same R environment effortlessly.

Members only
6 minutes read

Problem: β€œIt works on my machine!” πŸ™ˆ

Your code is polished, your directory structure contains all dependencies like data and scripts, everything is nicely bundled in a Rstudio project and version controlled in a git repository.

Your coworker thanks you 100 times and clones your repository.

He tries to run your code.


Bummer!

The code throws a couple of errors: some missing packages, some unknown functions. You check on your end again and the project works fine, you respond: β€œit works on my machine!”.

So what happened? πŸ€”

Your coworker does not have the same environment as you do. Think of missing packages and different package versions.

He has to manually figure out one by one which packages are missing and install them running install.packages(). This is cumbersome and might even break other scripts on his system.

Solution: reproducible environments with renv πŸ› οΈ

Follow us on Twitter

renv is an R package developed by R Studio to help creating reproducible environments.

It enables you to install packages on a project-by-project basis while also keeping track of the specific versions of packages you've used.

So if you switch between projects or a coworker opens up one of your projects, renv ensures that the exact R packages required for that project will be installed. πŸ”₯

background picture with networks
Productive R Workflow

This lesson is for members only! πŸ˜”
Become a member now to access the full course with a lifetime access!

Or Login

← Previous

Visit the past

Next β†’

Lumo: a clean quarto template

πŸŽ‰ 100 half-price seats available β€” 3 left! πŸ”₯