Search
Question: Is there a way to tell biocLite() to install a Bioconductor package only if it is not installed already?
1
gravatar for cristian
6 months ago by
cristian10
cristian10 wrote:

Is there a way to tell biocLite() to install a Bioconductor package only if it is not installed already?

At the moment, I am running this code:

source('https://bioconductor.org/biocLite.R')
biocLite(listOfBiocPackages, ask = FALSE, lib = 'output/software/r/package/installation/')

where listOfBiocPackages is a vector of characters with names of Bioconductor packages.

If I update listOfBiocPackages, it is going to reinstall all the other packages again. Is there a way to tell biocLite() to only install packages that are not installed yet?

ADD COMMENTlink modified 6 months ago by Mike Smith2.8k • written 6 months ago by cristian10
4
gravatar for Mike Smith
6 months ago by
Mike Smith2.8k
EMBL Heidelberg / de.NBI
Mike Smith2.8k wrote:

There might be an argument you can supply to biocLite(), but one strategy is that you can list packages that are already installed with installed.packages() and you can then use that to filter your installation vector, so something like:

notInstalled <- which( !listOfBiocPackages %in% rownames(installed.packages()) )

## check there's still something left to install
if( length(notInstalled) ) {
    biocLite(listOfBiocPackages[ notInstalled ])
}
ADD COMMENTlink modified 6 months ago • written 6 months ago by Mike Smith2.8k
1

FWIW setdiff(listOfBiocPackages, rownames(installed.packages())) does the same but is clearer and less typing than listOfBiocPackages[ which( !listOfBiocPackages %in% rownames(installed.packages()) ) ]

H.

ADD REPLYlink written 6 months ago by Hervé Pagès ♦♦ 13k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 140 users visited in the last hour