Skip to contents

This function reads the recorded package versions from a tarflowr project's metadata file (_tarflowr_meta.yaml) and uses the renv package to install those specific versions, recreating the original R environment.

Usage

tarflowr_restore_env(project_dir)

Arguments

project_dir

The path to the tarflowr project directory.

Details

This function is designed to make tarflowr projects highly reproducible. It provides a simple way for another user (or your future self) to ensure they are running the code with the same dependencies as the original author.

It will prompt the user to initialize an renv project if one is not already active in the current directory. It also checks if the current R version matches the version recorded in the metadata and will issue a warning if they differ.

Author

Andrew G. Brown

Examples

if (FALSE) { # \dontrun{
# Assuming a project has already been run in "./_my_project"

# This will attempt to install the exact package versions
# recorded in the project's metadata file.
tarflowr_restore_env(project_dir = "_my_project")
} # }