Created
November 27, 2018 04:43
-
-
Save tylerlittlefield/32c1a34961367d05b65ca1b30bfdb0fb to your computer and use it in GitHub Desktop.
Plot the language composition of tidyverse core packages
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(gh) | |
library(tidyverse) | |
library(jsonlite) | |
tidyrepos <- c("ggplot2", | |
"dplyr", | |
"tidyr", | |
"readr", | |
"purrr", | |
"tibble", | |
"stringr", | |
"forcats") | |
endpoint_str <- function(repo) glue::glue("/repos/tidyverse/{repo}/languages") | |
tidylangs <- sapply(tidyrepos, function(x) gh(paste0(endpoint_str(x)))) %>% | |
toJSON(pretty = TRUE) %>% | |
fromJSON() %>% | |
bind_rows() %>% | |
mutate(repo = tidyrepos) %>% | |
gather("lang", "bytes", -c("repo")) %>% | |
drop_na(bytes) %>% | |
group_by(repo) %>% | |
mutate(percentage = bytes / sum(bytes, na.rm = TRUE)) %>% | |
ungroup() %>% | |
arrange(repo) %>% | |
print(n = nrow(.)) | |
tidylangs %>% | |
ggplot(aes(lang, percentage, fill = lang)) + | |
geom_col(show.legend = FALSE) + | |
coord_flip() + | |
labs(x = NULL, y = NULL) + | |
facet_grid(rows = vars(repo), scales = "free_y") + | |
scale_y_continuous(labels = scales::percent) + | |
theme_bw() + | |
theme( | |
# text = element_text(family = "ProzaLibre-Regular"), | |
panel.grid.minor.x = element_blank(), | |
panel.grid.major.y = element_blank(), | |
plot.title = element_text(size = 30, hjust = 0.5) | |
) |
Author
tylerlittlefield
commented
Nov 27, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment