Is there a way to tell biocLite() to install a Bioconductor package only if it is not installed already?
1
1
Entering edit mode
cristian ▴ 10
@cristian-13977
Last seen 5.5 years ago

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?

bioclite package installation installation install • 1.7k views
ADD COMMENT
4
Entering edit mode
Mike Smith ★ 6.4k
@mike-smith
Last seen 9 hours ago
EMBL Heidelberg

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 COMMENT
1
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 696 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6