Search code examples
renvironmentcranbioconductorreproducible-research

Differentiate among packages installed through CRAN and Bioconductor [R]


I installed a bunch of R packages in a conda environment and I want to create something similar to conda env export does, but in R.

You can obtain package name and versioning from (credits):

ip = as.data.frame(installed.packages()[,c(1,3:4)])
ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
ip

.. but is there any way of knowing which repo each package is coming? (And then to install all packages in a row through install.packages(c("pck1", "pck2"...)) for CRAN-based or BiocManager::install(c("pck1", "pck2"...)) for bioconductor-based ones.)


Solution

  • BiocManager::install() also installs CRAN packages so that for the use case outlined it is not necessary to know where they come from. Also p = available.packages(repos = BiocManager::repositories()) has a column for Package and Repository so the source repository can be determined before installation, or by the join between installed and available packages