Implement Groundhog library in R package


Can someone tell me how to implement the groundhog package (mainly groundhog.library) inside the R package.

I have created a new R package and I want to make sure that in the future if there are new changes in the other dependent packages then my library doesn't get stuck because of any new version. I know a better solution for this is the groundhog library but not sure how to implement it in a new package.

I got the idea for the groundhog library from [95] Groundhog: Addressing The Threat That R Poses To Reproducible Research - Data Colada
Any new suggestions are welcome.



You shouldn't.

The way {groundhog} is organized, it should be used by the end user, the analyst loading packages and running the code. For that end user, if they replace library(xxx) with groundhog.library(xxx) in their script, they get to freeze the package versions within the script.

If you are a package developer, it's not for you to change package versions on the end user computer's! Same way your code should never run install.packages() or similar. What you can use is the DESCRIPTION file, to specify dependencies. Technically, you can require an exact version of a dependency:

    dplyr (== 1.0.0)

It is a bad idea! Because if you do that, you force your user to use only that version. If, for some reason, they want to use features of {dplyr} 1.5, but when you developed your package you required {dplyr} 1.0, they are forced to use either your package, or dplyr, not both. And in terms of development, if you release your package now, you should assume that you might not have the time and energy to update it every time one of its dependencies get updated.

So the best course of action is to set a minimum version of the dependencies in the DESCRIPTION, and then let the users load {groundhog}, {renv}, {packrat}, or whatever version management they want.


Thank you so much @AlexisW . That would help me proceed further.

Addtionally, Implement Groundhog library in R package - Stack Overflow.

This topic was automatically closed after 45 days. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.