[R] Upgrading R means I lose my packages

Michael Friendly friendly at yorku.ca
Thu Aug 28 15:31:19 CEST 2008


James Milks wrote:
> The title says it all.  Does anyone know of a way to save your packages 
> when you upgrade to a new version of R?  This may seem petty, but I'm 
> accumulating enough packages that having to download and install each of 
> them anew every time I install a new version of R is rather of a pain.  
> Ideally, I would like the new version of R to recognize the packages 
> I've installed on the previous version without needing to reinstall the 
> packages.  Is that possible?
> 
> My system: Mac OS 10.5.4.
> Current R version: 2.7.1
> 
> Thanks for any suggestions.  My apologies if this has been answered 
> before and my search missed it.
> 
> Jim Milks
> 
> Degree Candidate
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
What I find simplest (on Windows at least) is

# To reinstall packages from one R version to the next:
#Currently you can do

tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpkgs, file="c:/R/installed.rda")

#in the old version to get a list of packages you installed.  Then in the
#new version,

load("c:/R/installed.rda")
install.packages(installedpkgs)



-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list