Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.