Question: Is there a way to tell biocLite() to install a Bioconductor package only if it is not installed already?
1
gravatar for cristian
16 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 16 months ago by Mike Smith3.7k • written 16 months ago by cristian10
Answer: Is there a way to tell biocLite() to install a Bioconductor package only if it i
4
gravatar for Mike Smith
16 months ago by
Mike Smith3.7k
EMBL Heidelberg / de.NBI
Mike Smith3.7k 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 16 months ago • written 16 months ago by Mike Smith3.7k
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 16 months ago by Hervé Pagès ♦♦ 14k
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 16.09
Traffic: 268 users visited in the last hour