Skip to content

Instantly share code, notes, and snippets.

@seancarmody
Forked from hadley/cran-downloads.r
Created July 23, 2013 23:20
Show Gist options
  • Save seancarmody/6066996 to your computer and use it in GitHub Desktop.
Save seancarmody/6066996 to your computer and use it in GitHub Desktop.
library(XML)
library(stringr)
url <- "http://cran.r-project.org/report_cran.html"
raw_path <- tempfile()
download.file(url, raw_path, quiet = TRUE)
# Extract table
tables <- readHTMLTable(raw_path, stringsAsFactors = FALSE)
downloads <- tables[[13]]
downloads <- downloads[, c("file", "reqs")]
names(downloads) <- c("path", "hits")
# Take only paths
is_path <- str_detect(downloads$path, "^/")
downloads <- downloads[is_path, ]
downloads$hits <- as.numeric(downloads$hits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment