Is there a functionality like requirements.txt
in Python, where you can store a list of packages used into a file, and whenever other people want to run your programs and need to install the dependencies, they can just do pip install -r requirements.txt
.
I think, this helps a lot when deploying R script into production. If there is no such functionality, how do I replicate it?
As per the comments, you might want to look at building a package, and including the requirements in the DESCRIPTION file. If you're talking about putting a .R script "into production", you can put a function at the start to make sure the packages required are installed. Here's something along those lines that I have in my own package, and I can call
pkgLoad( <list of packages> )
at the beginning of any script to make sure the packages are installed and loaded. I include a list of my favourite packages, such that a call ofpkgLoad()
installs and loads all my usual suspects:Note I've built my favourite CRAN mirror into the function, so make sure you edit that for your own needs.