[R] install.packages and dependencies=TRUE

Duncan Murdoch murdoch.duncan at gmail.com
Tue Dec 17 19:08:04 CET 2013


So apparently not as simple as I thought it would be.  So I'll tell you 
what I actually do:

I have a number of packages under development, some on CRAN, some not.  
I also work in multiple builds of R pretty frequently, so I like to 
install all my packages and commonly used ones from other people.  So I 
put together a little script that I can run that will install or update 
a list of about 20 packages.  Here it is, with the names deleted.

# Script to install current versions of commonly used packages

installed <- rownames(installed.packages())
old <- old.packages()

oldoptions <- options(repos = 
c(CRAN="http://probability.ca/cran",CRANextra="http://www.stats.ox.ac.uk/pub/RWin"))
pkgs <-    ------ a character vector of packages on CRAN ------
oldPkgs <- old[intersect(pkgs, rownames(old)),,drop=FALSE]
if (length(oldPkgs))
   update.packages(oldPkgs = oldPkgs)
pkgs <- setdiff(pkgs, installed)
if (length(pkgs))
   install.packages(pkgs, dep=c("Depends", "Imports"))

options(repos = c(options("repos"), 
"R-forge"="http://R-Forge.R-project.org"))
pkgs <- ------ packages to install from R-forge ------
oldPkgs <- old[intersect(pkgs, rownames(old)),,drop=FALSE]
if (length(oldPkgs))
   update.packages(oldPkgs = oldPkgs)
pkgs <- setdiff("patchDVI", installed)
if (length(pkgs))
   install.packages(pkgs)

MyR <- ------ the source directory where I keep my own packages ------
pkgs <- ------ packages to install from local source ------
pkgs <- setdiff(pkgs, installed)
if (length(pkgs))
   install.packages(file.path(MyR, pkgs), type="source", repos=NULL)

options(oldoptions)



More information about the R-help mailing list