Created
August 18, 2018 08:52
-
-
Save jdeboer/bd8f7728339dc11d3479d56fa2645702 to your computer and use it in GitHub Desktop.
Generate a trend plot showing the cumulative downloads of Google Analytics R packages via RStudio's CRAN mirror. The data is accessed using the cranlogs package.
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
library(tidyverse) | |
packages <- c("ganalytics", "googleAnalyticsR", "RGoogleAnalyticsPremium", "RGA", "GAR") | |
df_raw <- cranlogs::cran_downloads(packages, from = "2013-04-09", to = Sys.Date() - 1L) | |
df <- tbl_df(df_raw) %>% | |
group_by(package) %>% mutate(count = cumsum(count)) %>% ungroup() %>% | |
filter(count > 0L) %>% | |
mutate(package = factor(package) %>% fct_reorder(count, max, .desc = TRUE)) | |
ggplot(df) + | |
aes(date, count, fill = package) + | |
geom_area(alpha = 0.5) + | |
scale_y_continuous(labels = scales::comma, name = "Cumulative downloads") + | |
scale_fill_discrete(name = "Package") + | |
ggtitle("Cumulative downloads of Google Analytics packages via RStudio's CRAN mirror.\n(Data accessed via the cranlogs package)") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment