Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way of replicating a list of installed CRAN packages (with the exact versions)?

Tags:

package

r

I develop code in R on multiple computers. Said code depends on many CRAN packages, and I want to make sure that the version of the packages my code depends on are kept in sync. So I am looking for a easy way of replicating a list of installed CRAN packages (with the same version) on another computer.

For people who also know Python, I am looking for an equivalent to pip freeze. Running pip freeze prints out a list of packages installed with their version. Then on another computer, I can feed this file back to pip and it installs the exact same version of all the packages listed. (What I do not want is something that installs the latest version on the other computer.)

Is there an easy way of doing this in R (or a tool that already does this), or do I have to roll my own?

like image 388
Christian Hudon Avatar asked Oct 07 '22 19:10

Christian Hudon


1 Answers

Have you looked at installed.packages() ?

R> IP <- installed.packages()
R> colnames(IP) 
 [1] "Package"   "LibPath"   "Version"   "Priority"  "Depends"   "Imports" 
 [7] "LinkingTo" "Suggests"  "Enhances"  "OS_type"   "License"   "Built"  
R> dim(IP)
[1] 284  12  
R>    

You could then roll a corresponding install.packages() over it on the other side, possibly with an additional layer of fetching versions from the 'Archive' section on CRAN.

like image 146
Dirk Eddelbuettel Avatar answered Oct 10 '22 05:10

Dirk Eddelbuettel