[R] install.packages and dependencies=TRUE

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Dec 17 19:18:12 CET 2013


The obvious idea to set up a local repository works.  It takes 5 mins at 
most.

On 17/12/2013 18:08, Duncan Murdoch wrote:
> 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)
>
> ______________________________________________
> 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.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list