Packrat bundles with different R versions - suggestions and alternatives

Yes I agree with that, it is not conventional. You would have to tweak a bit the standard way of using renv but I think it is possible - and maybe some wrapper could be useful to you.

Look at the doc of renv to understand how it works.

  • renv::init(bare = TRUE) would allow you to initialize a renv project in your data folder where you want. bare = TRUE means the packages discovery won't be automatic.
  • You can then use renv::hydrate() to install in this project the dependencies you want. Look at the arguments for details. Either manually or you can use renv::dependencies() to explicitly search for dependencies in some specific path. Here you need I guess renv::dependencies(path = "../scripts/proj1) when you are in data/proj1. Look also at the argument to see how to change the defaults.
  • When you add a new library in scripts, this will be the trickiest. Normally, you would use renv::install to install the library, and renv::snapshot to capture the state. you would need to provide I think the proj argument to your data folder and snapshot using simple type (not dependencies guess).

As you see, you definitely won't be able to use all the defaults in renv but I think with all the different arguments in the functions, you can tweak as you need.

I suggest you try something and if you manage to work something out, I am really interesting to know how it would work. I guess it will be interesting for others in your case, and maybe there is some improvement to make in renv for this special workflow.

What do you think ?

1 Like