Last active
December 3, 2025 14:49
-
-
Save matt-dray/5fd4d42e7bf17cf499e65be99b005efe to your computer and use it in GitHub Desktop.
Look for packages in an R project and either (a) install them (without asking) or (b) add them as imports to a DESCRIPTION file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Isolate packages used in project | |
| used <- renv::dependencies()$Package | |
| base <- rownames(installed.packages(priority = "base")) | |
| pkgs <- setdiff(used, base) # don't install base packages | |
| # To install: | |
| purrr::walk(pkgs, \(pkg) pak::pak(pkg, ask = FALSE)) | |
| # To add to imports: | |
| purrr::walk(pkgs, usethis::use_package) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment