Get and read the log - show/hide code

yesterday <- Sys.Date() - 1
year <- format(Sys.Date() - 1, "%Y")
url <- paste0("http://cran-logs.rstudio.com/", year, "/", yesterday, ".csv.gz")
filename <- paste0(yesterday, ".csv.gz")
if (!file.exists(filename)) {
  cat(paste0("Downloading: ", filename))
  download.file(url, destfile = filename)
}
## Downloading: 2025-01-04.csv.gz
cranlog <- read.csv(gzfile(filename))

Yesterday (2025-01-04), there were 3,944,974 distinct package downloads and 51,078 unique users on cran.rstudio.com.


By R version

barplot(table(cranlog$r_version), las = 2, cex.names = 1.3)

By OS

r_os_macos <- gsub("^darwin.*", "MacOS", cranlog$r_os)
r_os <- gsub("mingw32", "Windows", r_os_macos)
barplot(table(r_os))

By Architecture

barplot(table(cranlog$r_arch), cex.names = .8)

By Country

Uses two letter ISO country code.

US downloads of 2622214, dwarf other countries and are therefore excluded from the chart for clarity. We also drop all the countries with less than 10,000 downloads.

country_data <- table(cranlog$country[cranlog$country != "US"])
barplot(country_data[country_data > 10000], las = 2, cex.names = .9)

Or if you’d prefer a straight up top 20, here it is:

head(sort(table(cranlog$country), decreasing = T), 20)
## 
##      US      CN      DE      GB      IN      JP      KR      HK      CH      ID 
## 2622214  167718   71718   70146   46399   46134   32343   31100   26270   25073 
##      CA      ES      FR      TR      TZ      IT      TW      ZA      NL      PL 
##   24079   24016   21947   19585   19442   18329   14811   11083   10065    9826

Another half-baked sellorm rough cut.