Last active
August 23, 2018 09:33
-
-
Save zkamvar/15ae71c7c0009c5dd3203bff2bab32ef to your computer and use it in GitHub Desktop.
Plotting the cumulative number of downloads for poppr over time
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('cranlogs') | |
library('ggplot2') | |
library('ggthemes') | |
library('lubridate') | |
library('dplyr') | |
releases <- tibble::tribble( | |
~version, ~date, ~size, | |
"1.0.0", lubridate::ymd("2013-04-26"), "2.5M", | |
"1.0.1", lubridate::ymd("2013-07-03"), "2.5M", | |
"1.0.3", lubridate::ymd("2013-08-21"), "2.5M", | |
"1.0.4", lubridate::ymd("2013-12-04"), "2.7M", | |
"1.0.5", lubridate::ymd("2013-12-13"), "2.4M", | |
"1.0.6", lubridate::ymd("2014-03-05"), "2.9M", | |
"1.1.0", lubridate::ymd("2014-07-24"), "1.9M", | |
"1.1.1", lubridate::ymd("2014-07-27"), "1.9M", | |
"1.1.2", lubridate::ymd("2014-07-29"), "1.8M", | |
"1.1.3", lubridate::ymd("2015-02-03"), "1.9M", | |
"1.1.4", lubridate::ymd("2015-02-06"), "1.9M", | |
"1.1.5", lubridate::ymd("2015-05-13"), "1.4M", | |
"2.0.0", lubridate::ymd("2015-07-08"), "2.1M", | |
"2.0.1", lubridate::ymd("2015-07-14"), "2.1M", | |
"2.0.2", lubridate::ymd("2015-07-18"), "2.1M", | |
"2.1.0", lubridate::ymd("2015-12-01"), "2.7M", | |
"2.1.1", lubridate::ymd("2016-03-15"), "2.7M", | |
"2.2.0", lubridate::ymd("2016-06-13"), "2.4M", | |
"2.2.1", lubridate::ymd("2016-08-29"), "3.8M", | |
"2.3.0", lubridate::ymd("2016-11-23"), "4.0M", | |
"2.4.0", lubridate::ymd("2017-04-10"), "3.9M", | |
"2.4.1", lubridate::ymd("2017-04-14"), "3.9M", | |
"2.5.0", lubridate::ymd("2017-09-11"), "3.9M", | |
"2.6.0", lubridate::ymd("2018-01-08"), "3.9M", | |
"2.6.1", lubridate::ymd("2018-01-15"), "3.5M", | |
"2.7.0", lubridate::ymd("2018-03-16"), "3.5M", | |
"2.7.1", lubridate::ymd("2018-03-16"), "3.5M", | |
"2.8.0", lubridate::ymd("2018-05-19"), "3.5M", | |
"2.8.1", lubridate::ymd("2018-08-22"), "3.5M" | |
) | |
cols <- RColorBrewer::brewer.pal(3, "Set1") | |
releases$type <- with(releases, case_when( | |
gsub("(\\d).\\d.\\d", "\\1.0.0", version) == version ~ "major", | |
gsub("(\\d.\\d).\\d", "\\1.0", version) == version ~ "minor", | |
gsub("(\\d.\\d).\\d", "\\1.0", version) != version ~ "patch" | |
)) | |
x <- cran_downloads(packages = "poppr", from = c("2013-04-26"), to = Sys.Date()) | |
x %>% | |
mutate(total = cumsum(count)) %>% | |
ggplot(aes(y = total, x = date)) + | |
geom_line(color = cols[2], size = 1.5) + | |
geom_vline(aes(xintercept = as.numeric(date), alpha = type, linetype = type), | |
data = releases, color = cols[1]) + | |
scale_alpha_discrete(range = c(1, 0.1)) + | |
theme_fivethirtyeight() + | |
theme(text = element_text(size = 16)) + | |
labs(list(title = "Poppr downloads from CRAN", | |
alpha = "Release", | |
lty = "Release")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment