Search code examples
rbioconductorcran

Get the current numbers of CRAN packages and Bioconductor packages


I am trying to insert the current number of CRAN packages and the number of Bioconductor packages to a markdown file.

I have tried this:

length(available.packages(available_packages_filters = c("CRAN")))

I got

[1] 272867

This is different from the number on the CRAN site (16081). Any suggestions would be appreciated.


Solution

  • available.packages() returns a matrix so you need to use nrow to get number of packages. However, as mentioned by @MichaelChirico note that the number might not be accurate as shown on the CRAN website because of syncing schedules.

    CRANpackages <- available.packages()
    nrow(CRANpackages)
    #[1] 16068
    

    As far as Bioconductor packages are concerned, I am not aware about a function which returns the number of packages but you can get the number from their website using this small scraping script.

    library(rvest)
    url <- 'https://www.bioconductor.org/packages/release/bioc/'
    biocPackages <- url %>% read_html() %>% html_table() %>%.[[1]]
    nrow(biocPackages)
    #[1] 1905