Last active
December 22, 2021 02:44
-
-
Save adamhsparks/476ec71cc9a23adf8fe61fc78a86635c to your computer and use it in GitHub Desktop.
Tracks my R package downloads 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(dplyr) | |
library(ggplot2) | |
library(lubridate) | |
library(cranlogs) | |
library(janitor) | |
dl <- | |
cran_downloads( | |
package = c( | |
"bomrang", | |
"GSODR", | |
"getCRUCLdata", | |
"nasapower", | |
"hagis", | |
"chirps", | |
"ascotraceR" | |
), | |
from = "2016-09-01" | |
) | |
plot_data <- | |
dl %>% | |
mutate(date = as.Date(date)) %>% | |
mutate(ym = format(date, '%Y-%m')) %>% | |
mutate(ym = ymd(ym, truncated = 1)) | |
ggplot(plot_data, aes(x = date, y = count, group = package)) + | |
geom_area(aes(colour = package, | |
fill = package)) + | |
guides(fill = "none", color = "none") + | |
xlab("Year - Month") + | |
ylab("Daily Downloads") + | |
labs( | |
title = "R package daily downloads", | |
caption = paste0( | |
"There have been ", | |
summarise(dl, sum(count)), | |
" total downloads.\n", | |
"Source: RStudio Cloud Server CRAN Mirror" | |
) | |
) + | |
facet_wrap(package ~ ., scales = "free_y") | |
plot_data %>% | |
group_by(package) %>% | |
summarise(sum(count)) %>% | |
ggplot(aes(x = package, y = `sum(count)`)) + | |
geom_bar(stat = "identity", aes(fill = package, colour = package)) + | |
ylab("Downloads") + | |
labs(title = "R Package Downloads") + | |
theme(legend.position = "none") | |
library(dplyr) | |
library(ggplot2) | |
library(lubridate) | |
library(cranlogs) | |
library(janitor) | |
dl <- | |
cran_downloads( | |
package = c( | |
"bomrang", | |
"GSODR", | |
"getCRUCLdata", | |
"nasapower", | |
"hagis", | |
"chirps", | |
"ascotraceR" | |
), | |
from = "2016-09-01" | |
) | |
plot_data <- | |
dl %>% | |
mutate(date = as.Date(date)) %>% | |
mutate(ym = format(date, '%Y-%m')) %>% | |
mutate(ym = ymd(ym, truncated = 1)) | |
ggplot(plot_data, aes(x = date, y = count, group = package)) + | |
geom_area(aes(colour = package, | |
fill = package)) + | |
guides(fill = "none", color = "none") + | |
xlab("Year - Month") + | |
ylab("Daily Downloads") + | |
labs( | |
title = "R package daily downloads", | |
caption = paste0( | |
"There have been ", | |
summarise(dl, sum(count)), | |
" total downloads.\n", | |
"Source: RStudio Cloud Server CRAN Mirror" | |
) | |
) + | |
facet_wrap(package ~ ., scales = "free_y") | |
plot_data %>% | |
group_by(package) %>% | |
summarise(sum(count)) %>% | |
ggplot(aes(x = package, y = `sum(count)`)) + | |
geom_bar(stat = "identity", aes(fill = package, colour = package)) + | |
ylab("Downloads") + | |
labs(title = "R Package Downloads") + | |
theme(legend.position = "none") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment