Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move r packages to new computer which has no internet

Tags:

installation

r

Normally I install packages using:

install.packages("foo") 

and a Repo over the internet. But I have a new machine now where I want to replicate the packages from my existing installation without having to pull everything off the internet all over again. (I've a ton of packages and slow internet access)

Both machines are Windows and run the same R version. (2.13.1)

Is there a way to do this? Closest I can get is I know I can install from local zip files using:

install.packages("pathtozip", repos = NULL)

But does R store all Zips somewhere? I found a few in locations like:

C:\Documents and Settings\foouser\Local Settings\Temp\RtmpjNKkyp\downloaded_packages

But not all.

Any tips?

like image 988
curious_cat Avatar asked Feb 25 '13 05:02

curious_cat


2 Answers

The function .libPaths will give you a vector of all the libraries on your machine. Run this on your old machine to find all of them. You can simply copy all these files into the libraries on your new machine (run .libPaths on it too to find out where).

Alternatively, if you want to set up a real repository (i.e. basically a CRAN mirror) on your computer or on a network drive you can update, you can put binary or source packages into a folder and run tools::write_PACKAGES on that folder. You can them run install.packages using the contriburl argument and point it to your repository folder.

like image 192
sebastian-c Avatar answered Oct 16 '22 00:10

sebastian-c


All packages that you have installed are stored in a folder called win-library\r-version, for example, C:\Users\Ehsan\Documents\R\win-library\2.15 so, it is enough to copy all the folders inside 2.15 to the same folder in your new machine. because you have the same version of R you do not need to update them by update.packages().

like image 12
Ehsan Masoudi Avatar answered Oct 16 '22 00:10

Ehsan Masoudi