install.packages("Rcmdr", dependencies=TRUE)
library(Rcmdr)
...will also install and load nearly every other package you've ever needed to use (except ggplot2, Hmisc, and rms/design). This saved me a lot of time trying to remember which packages I normally use and installing them one at a time. Specifically, installing and loading Rcmdr will install the following packages from CRAN: fBasics, bitops, ellipse, mix, tweedie, gtools, gdata, caTools, Ecdat, scatterplot3d, ape, flexmix, gee, mclust, rmeta, statmod, cubature, kinship, gam, MCMCpack, tripack, akima, logspline, gplots, maxLik, miscTools, VGAM, sem, mlbench, randomForest, SparseM, kernlab, HSAUR, Formula, ineq, mlogit, np, plm, pscl, quantreg, ROCR, sampleSelection, systemfit, truncreg, urca, oz, fUtilities, fEcofin, RUnit, quadprog, mlmRev, MEMSS, coda, party, ipred, modeltools, e1071, vcd, AER, chron, DAAG, fCalendar, fSeries, fts, its, timeDate, timeSeries, tis, tseries, xts, foreach, DBI, RSQLite, mvtnorm, lme4, robustbase, mboost, coin, xtable, sandwich, zoo, strucchange, dynlm, biglm, rgl, relimp, multcomp, lmtest, leaps, effects, aplpack, abind, RODBC.
Anyone else have a solution for batch-installing packages you use on a new machine or fresh R installation? Leave it in the comments!
If the old system is still available you can use
ReplyDeleteinstalled.packages()[,1]
to get a list of all installed packages. Save it somewhere:
write.table(installed.packages()[,1], row.names=F, col.names=F, file="Rpackages.txt")
and pass it as a character vector to install.packages() on the new system to get the same setup.
I have a R-script called "maintenance.R" which I've used to originally install the packages, e.g:
ReplyDelete# Install Bioconductor
source("http://bioconductor.org/biocLite.R")
biocLite()
# Install Bioconductor packages
source("http://bioconductor.org/biocLite.R")
biocLite("affyQCReport")
biocLite("latticeExtra")
...
# Install R-packages
install.packages("gap")
install.packages("matlab")
install.packages("lattice")
And then I have also commands for updating all installed packages, e.g.:
#Update R packages
update.packages(ask=FALSE)
# Update installed Bioconductor packages
source("http://bioconductor.org/biocLite.R")
update.packages(repos=biocinstallRepos(), ask=FALSE)
..For me this is very easy way to install and update all the packages, and if I need to set up a new machine, new install of R or whatever, it is really simple to just run that script.
If you use OS X you could refer to:
ReplyDeletehttp://onertipaday.blogspot.com/2008/10/r-upgrade-on-mac-os-x-1055-leopard.html
I find Robert's solution in principle easier but since I'm just beginning to learn my way with R, may I know how would you pass "Rpackages.txt" as a character vector to the install.packages function?
ReplyDeleteMany thanks in advance,
Ruben
On the new system you can load the package list using read.table or scan:
ReplyDeletepackages <- scan("Rpackages.txt", "character")
Then, to avoid reinstalling packages that are already there, I would use
install.packages(packages[!(packages %in% installed.packages())], dependencies=T)
to get all the missing packages in place.