["r","python"]
Virtual environment in R?

I've found several posts about best practice, reproducibility and workflow in R, for example: How to increase longer term reproducibility of research (particularly using R and Sweave) Complete substantive examples of reproducible research using R One of the major preoccupations is ensuring portability of code, in the sense that moving it to a new machine (possibly running a different OS) is relatively straightforward and gives the same results. Coming from a Python background, I'm used to the concept of a virtual environment. When coupled with a simple list of required packages, this goes some way to ensuring that the installed packages and libraries are available on any machine without too much fuss. Sure, it's no guarantee - different OSes have their own foibles and peculiarities - but it gets you 95% of the way there. Does such a thing exist within R? Even if it's not as sophisticated. For example simply maintaining a plain text list of required packages and a script that will install any that are missing? I'm about to start using R in earnest for the first time, probably in conjunction with Sweave, and would ideally like to start in the best way possible! Thanks for your thoughts.
It looks like there is another option from RStudio devs, renv. It's available on CRAN and supersedes Packrat. In short, you use renv::init() to initialize your project library, and use renv::snapshot() / renv::restore() to save and load the state of your library. I prefer this option to conda r-enviroments because here everything is stored in the file renv.lock, which can be committed to a Git repo and distributed to the team.