Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transferring installed R packages to R on another computer

Tags:

linux

package

r

I have R installed on one linux computer where there are number of packages installed. Now I am setting up R on another linux computer. Installing R is easy from their repository but I will have to install many packages using

install.packages("pkgname") 

which will involve repeat downloading as well. Is there any way I can copy all the installed packages from first computer to the second one? Thanks for your help.

like image 905
rnso Avatar asked Oct 29 '25 05:10

rnso


1 Answers

I would recommend against this approach. Some of those packages will have been installed from source which includes compile-time checks based on what is installed on "computer one" and that will not necessarily be true on the other computer.

You have two basic choices

  1. Use binary package (ie r-cran-pkgname for various packages). These will work but a) not all of CRAN exists that way and b) they may lag the current release.
  2. Install from source. Just run saveRDS(installed.packages(), file="/tmp/pkgs.rds") on the first computer and pkgs <- readRDS("/tmp/pkgs.rds"); install.packages(rownames(pkgs)) on the second after transfering the file.
like image 75
Dirk Eddelbuettel Avatar answered Oct 30 '25 21:10

Dirk Eddelbuettel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!