knitr::opts_chunk$set( comment = "#>", tidy = FALSE, error = FALSE)
Download logs from the RStudio CRAN mirror
RStudio publishes the download logs from their CRAN package mirror daily at http://cran-logs.rstudio.com.
This R package queries a web API maintained by R-hub serving a database, also maintained by R-hub, that contains the daily download numbers for each package.
The RStudio CRAN mirror is not the only CRAN mirror, but it's a popular one: it's the default choice for RStudio users. The actual number of downloads over all CRAN mirrors is unknown.
You can install cranlogs
from CRAN:
install.packages("cranlogs")
Or get the development version from Github:
# install.packages("remotes") remotes::install_github("r-hub/cranlogs")
It has a very simple API. By default it shows the total number of package downloads from the last day for which data is available.
library(cranlogs) cran_downloads()
The last week (6 days prior to the last day for which data is available), or the last month (29 days prior to the last day for which data is available) can be also easily queried:
cran_downloads(when = "last-week")
The package
argument queries a specific package:
cran_downloads(when = "last-week", package = c("magrittr", "dplyr"))
Alternative intervals can also be specified:
cran_downloads(package = "plyr", from = "2014-01-01", to = "2014-02-01")
For downloads of R itself, give "R"
instead of a package:
cran_downloads("R")
Last day for which data is available:
cran_top_downloads()
Last week (6 days prior to the last day for which data is available):
cran_top_downloads("last-week")
See the GitHub repo of the API of the CRAN downloads database.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.