On Jul 1, 2014, at 1:50 PM, G. Sawitzki wrote:
This is a late follow up to
<https://stat.ethz.ch/pipermail/r-sig-mac/2013-April/010045.html>
Is there a useful implementation to move existing packages?
This comes up if there is a new R release and you want your old
collection updated, but work on a system that does versioning (e.g. OS X).
The message referred above suggests to use the GUI Package Installer,
but at least on OS X this functionality does not exist.
On a command level, this might be implemeted as a variant of
update.packages() with an additional parameter old.lib.loc (or a changed
semantics for oldPkgs: get a list of packages from old.lib.loc, and
update these to lib.loc.
The design problem is that R does not keep a memory of where a package
has been installed. So an iteration over a list of repositories might be
needed.
Not sure what the issue is, and I think your understanding of the library system may be inadequate. The example in that message was using the standard Frameworks location. If you needed to get a more expansive list of R libraries, then execute:
.libPaths()
You could also point list.dirs() at an old ../../library/ or two to gather a list of folder names.
all <- list.dirs("/Library/Frameworks/R.framework/Versions/3.1/Resources/library", recursive=FALSE, full.names=FALSE)
all[1:10]
[1] "A2R" "abind" "acepack" "Acinonyx" "actuar" "ada"
[7] "adabag" "ade4" "adegenet" "adehabitat"
It doesn't seem to be that difficult to iterate over the contents of that vector.
for (loc in .libPaths() ) {
a=rownames(installed.packages(loc))
install.packages(a[!(a %in% rownames(installed.packages()))])
}