5

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?

2 Answers2

4

Create a requirements file with any delimiter between packages and its version version. For eg.

data.table 1.11.4
DBI 1.0.0
curl 3.2

And then install it by parsing the file:

#!/usr/bin/bash
while IFS=" " read -r package version; 
do 
  Rscript -e "devtools::install_version('"$package"', version='"$version"')"; 
done < "requirements.txt"
Keith Hughitt
  • 4,860
  • 5
  • 49
  • 54
3

You can use packrat with your project. link

c1au61o_HH
  • 867
  • 7
  • 14