[R] Selective package installation

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri May 22 12:03:17 CEST 2015

On 18.05.2015 09:14, Partha Sinha wrote:
> I am using Win 7, 32 bit and R 3.2.0
> I want to install few packages via script.
> The script should first check if the package is already installed (I
> dont want update).

assume the packages are given in a character vector pkg.

pkg <- c("MASS", "A")


inst <- installed.packages()[,1]
install.packages(setdiff(pkg, inst))

Uwe Ligges

> If the package is already there , then it would go
> to the next package in my list.

> How can I do this ?
> Parth
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

More information about the R-help mailing list