Skip to content

Instantly share code, notes, and snippets.

@arthurgailes
Created August 14, 2023 12:57
Show Gist options
  • Save arthurgailes/1a593442f49a21ba969c8dce79a3dd47 to your computer and use it in GitHub Desktop.
Save arthurgailes/1a593442f49a21ba969c8dce79a3dd47 to your computer and use it in GitHub Desktop.
Quickly show time series for R package downloads
# quick R script for seeing the trends in downloads for a package
library(cranlogs)
library(ggplot2)
library(collapse)
library(lubridate)
package <- "shiny"
# get downloads for a specific date
x <- cran_downloads(packages=shiny, from="2015-06-01", to="2023-08-14")
head(x)
x |>
qTBL() |>
fmutate(date = floor_date(date, "month")) |>
fsubset(date != max(date)) |>
fgroup_by(date) |>
fsummarize(count = fsum(count)) |>
ggplot() +
geom_line(aes(date, count)) +
scale_y_continuous(labels = scales::label_comma()) +
theme_minimal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment