Skip to content

Instantly share code, notes, and snippets.

@jokergoo
Created October 2, 2022 15:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jokergoo/2d9c97033cc35379a0ee63f54f3050d5 to your computer and use it in GitHub Desktop.
Save jokergoo/2d9c97033cc35379a0ee63f54f3050d5 to your computer and use it in GitHub Desktop.
Number of downloads from CRAN/Bioc/conda
library(rvest)
library(jsonlite)
downloads_from_conda = function(pkg) {
x = read_html(paste0("https://anaconda.org/search?q=r-", pkg))
tb = html_nodes(x, "table") %>% html_table()
if(length(tb) > 0) {
tb = tb[[1]]
sum(tb[, 2])
} else {
0
}
}
downloads_from_cran = function(pkg) {
x = read_json(paste0("https://cranlogs.r-pkg.org/downloads/total/2001-01-01:2114-01-01/", pkg))
x[[1]]$downloads
}
downloads_from_bioc = function(pkg) {
df = read.table(paste0("http://bioconductor.org/packages/stats/bioc/", pkg, "/", pkg, "_stats.tab"), header = TRUE)
sum(df[df[, "Month"] != "all", "Nb_of_downloads"])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment