Created
April 30, 2019 13:03
-
-
Save zross/b64657b05156d43cf81dbdd093df5c13 to your computer and use it in GitHub Desktop.
For getting download counts for spatial packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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