Last active
June 29, 2021 09:37
-
-
Save darokun/5de0fc3d9e93ccd01dcb707570cb7afa 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
# Causallang screening process animated plot | |
# author: Daloha Rodriguez-Molina @darokun | |
# load packages | |
library(tidyverse) | |
library(gganimate) | |
library(readxl) | |
library(here) | |
# data | |
data_screening <- read_excel(here::here("R", "causallang", "causallang_screening_progress.xlsx")) %>% | |
map_if(is.numeric, function(x) x*100) %>% | |
map_if(is.numeric, round, digits = 2) %>% | |
as.tibble() %>% | |
pivot_longer(!reviewer_id, names_to = "checkpoint", values_to = "percentage_screened") %>% | |
mutate(checkpoint = as.integer(checkpoint)) | |
# View(data_screening) # NOT RUN | |
# plot | |
p <- ggplot(data = data_screening, | |
aes(x = reorder(reviewer_id, percentage_screened), | |
y = percentage_screened, | |
fill = reviewer_id)) + | |
geom_bar(stat = "identity") + | |
ylab("Percentage screened") + | |
scale_y_continuous(limits = c(0, 105)) + | |
theme(legend.position = "none", | |
axis.text.y = element_blank(), | |
axis.title.y = element_blank(), | |
axis.ticks.y = element_blank(), | |
panel.grid.major = element_blank(), | |
panel.grid.minor = element_blank(), | |
panel.background = element_blank()) + | |
geom_text(aes(label = reviewer_id), | |
vjust = 1, | |
hjust = -0.1, | |
color = "black", | |
size = 3.5) + | |
coord_flip() + | |
## gganimate code | |
labs(title = "Causallang project, screening checkpoint: {frame_time}", | |
caption = "@darokun") + | |
transition_time(checkpoint) + | |
ease_aes("linear") | |
# save plot as a gif | |
p <- animate(p) | |
magick::image_write(p, path = here::here("R", "causallang","screening.gif")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment