CredibilityLab / groundhog

Reproducible R Scripts Via Date Controlled Installing & Loading of CRAN & Git Packages
https://groundhogr.com/
GNU General Public License v3.0
78 stars 4 forks source link

groundhog.library() does not work for dynamic character vector of packages #62

Closed johannjacoby closed 3 years ago

johannjacoby commented 3 years ago

I would like to be able to specify all packages used at the top in a vector (for further use elsewhere) and then go through them using groundhog without having to spell out each package name again. But that does not seem to work. Not sure if I am doing smething wrong, I don't understand the function groundhog.library() enough to be able to see my mistake...

E.g., this works fine:

library(groundhog)
groundhog.day="2020-10-01"
groundhog.library(pkg="lme4", date=groundhog.day)
groundhog.library(pkg="readxl", date=groundhog.day)

but this doesn't:

library(groundhog)
groundhog.day="2020-10-01"
touse <- c("readxl","lme4")
for (p in touse) {groundhog.library(pkg=p, date=groundhog.day)}
urisohn commented 3 years ago

This is a known limitation, it is due to the flexibilty in grounhog.library() accepting both 'lme4' and lme4 (without quotes). We wanted to emulate both library() and install.packages(), the former accepts the value without quotes but the latter does not.

But the good news is that groundhog_1.2.0 will accept the argument pkg to be a vector, so you will be able to do

touse <- c("readxl","lme4")
groundhog.library(touse, groundhog.day)

Plan is to submit groundhog_1.2.0 to CRAN this week.

johannjacoby commented 3 years ago

Amazeballs! Cool, thank you!