Skip to content

Instantly share code, notes, and snippets.

@zross
Created April 30, 2019 13:03
Show Gist options
  • Save zross/b64657b05156d43cf81dbdd093df5c13 to your computer and use it in GitHub Desktop.
Save zross/b64657b05156d43cf81dbdd093df5c13 to your computer and use it in GitHub Desktop.
For getting download counts for spatial packages
# Grab the list of spatial packages from the R Task View (Bivand)
# and get the count of monthly downloads
library(rvest)
library(dplyr)
spatial_task_view <- read_html("https://cran.r-project.org/web/views/Spatial.html")
res <- spatial_task_view %>%
html_nodes(xpath = "/html/body/ul[1]") %>%
html_children() %>%
html_text()
pkgs <- res %>%
stringr::str_replace_all("\\(core\\)", "") %>%
stringr::str_trim() %>%
cranlogs::cran_downloads(packages = ., when = "last-month") %>%
group_by(package) %>%
summarize(count = sum(count)) %>%
arrange(desc(count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment