Is there any easy way to replicate R packages between two machines?
3
3
Entering edit mode
9.3 years ago
Parham ★ 1.6k

Hi,

I am wondering if there is any easy way to have same packages of an existing R on machine 1 on a newly installed R on machine 2? Or I have to go through them and install them one by one manually?

Thanks in advance!

replicate packages R • 5.9k views
ADD COMMENT
1
Entering edit mode
9.3 years ago

Also not sure if it helps, but using

.libPaths()

will show the folders where R packages were installed, you can then copy those folders manually

ADD COMMENT
0
Entering edit mode

That looks very straightforward. So they don't need to be installed? Just if the folders are available in that path the libraries can be loaded?

ADD REPLY
0
Entering edit mode

Hi! Yes, they should work if the lib path on the other computer points to the correct directory. I've used this in one of my recent tools:

The installer was just going through package names and invoking install.packages(..., lib = /path/to/libs) while all scripts had .libPaths(/path/to/libs); library(...) and it worked fine

ADD REPLY
0
Entering edit mode

That's great, thanks a lot.

ADD REPLY
0
Entering edit mode
9.3 years ago

Not sure if it is worth the effort, but you could use something like Docker to share a specific environment between computers.

ADD COMMENT
0
Entering edit mode

Thanks but it seems that's too complicated for me.

ADD REPLY
0
Entering edit mode
9.3 years ago

You can write a short script to use the built-in installed.packages() function to enumerate the existing packages on machine A and then use install.packages() to install those packages on machine B, remembering your friend the dependencies flag. I often run into snags when I attempt to install a binary package from a repository, only to find that the binary in bioconductor (for example) will not run on my current version of R on my particular platform. I tend to install from source for this reason. Specifying or pulling down source code would also let you be sure that you are installing the same version of each package, as you may run into trouble if you have version 2.11 on machine A and verison 2.16 on machine B.

ADD COMMENT

Login before adding your answer.

Traffic: 1623 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6