Created
January 2, 2020 23:19
-
-
Save hadley/dea1feacd6968346d12cf0237b2007bd to your computer and use it in GitHub Desktop.
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) | |
library(gh) | |
library(lubridate) | |
library(glue) | |
repo <- tibble(json = unclass(gh("/user/repos", .limit = Inf))) | |
repo <- repo %>% | |
hoist(json, | |
owner = c("owner", "login"), | |
repo = "name", | |
private = "private", | |
updated = "updated_at", | |
size = "size", | |
.remove = FALSE | |
) %>% | |
mutate(updated = parse_datetime(updated)) %>% | |
filter(year(updated) >= 2019, size > 0) | |
repo | |
commits_json <- pmap(repo, function(owner, repo, ...) { | |
gh("/repos/:owner/:repo/commits", | |
owner = owner, | |
repo = repo, | |
author = "hadley", | |
since = "2019-01-01", | |
until = "2020-01-01", | |
.limit = Inf | |
) | |
}) | |
saveRDS(commits_json, "~/Desktop/commits.rds") | |
commits <- tibble(json = commits_json %>% | |
discard(is.character) %>% | |
map(unclass) %>% | |
unlist(recursive = FALSE)) | |
commits <- commits %>% hoist(json, | |
author = c("author", "login"), | |
committer = c("committer", "login"), | |
date = c("commit", "author", "date"), | |
.remove = FALSE | |
) %>% mutate( | |
date = parse_datetime(date), | |
day = as.Date(date), | |
wday = wday(date, label = TRUE), | |
time = update(with_tz(date, "US/Central"), yday = 1, year = 2019) | |
) | |
commits %>% | |
count(day) %>% | |
ggplot(aes(day, n)) + | |
geom_point() | |
commits %>% | |
ggplot(aes(fct_shift(wday, 1), time)) + | |
ggbeeswarm::geom_quasirandom(bandwidth = 0.2) + | |
scale_y_datetime(date_labels = "%H:%M") | |
commits %>% | |
ggplot(aes(fct_shift(wday, 1), time)) + | |
geom_jitter() + | |
scale_y_datetime(date_labels = "%H:%M") | |
commits %>% | |
ggplot(aes(time, fct_rev(fct_shift(wday, 1)))) + | |
ggridges::geom_density_ridges2(bandwidth = 30 * 60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment