Created
December 18, 2019 03:00
-
-
Save brettkobo/bc48819d3839f99e09152f5032aca82a to your computer and use it in GitHub Desktop.
R script looking at # of hours in meetings.
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(lubridate) | |
devtools::install_github("andrie/gcalendr") | |
library(gcalendr) | |
calendar_auth() | |
calendar_ids <- calendar_list() | |
events <- calendar_events("email-address@domain.com", days_in_past = 480) | |
table <- events %>% | |
filter(!grepl('PTO|UK|Marketing Summit', summary)) %>% | |
mutate(hour_per_meeting = ((end_datetime - start_datetime)/60)/60) %>% | |
group_by(date = floor_date(start_datetime, "week")) %>% | |
summarise(num_of_events = n(), total_hours = sum(hour_per_meeting), perc_in_meetings = total_hours/(40*5)) %>% | |
filter(date > as.Date("2018-08-01"), date <= Sys.Date()) | |
graph <- table %>% | |
ggplot() + | |
geom_line(aes(date, total_hours), color = "blue", size = 1) + | |
geom_smooth(aes(date, total_hours), color = "red", alpha = .5, size = .5) + | |
scale_x_datetime(breaks = "month", date_labels = "%m-%d-%y") + | |
scale_y_continuous(breaks = seq(0, 61, 10)) + | |
theme(axis.text.x = element_text(angle = 45, hjust = 1), | |
plot.title = element_text(hjust = 0.5)) + | |
geom_vline(xintercept = as.POSIXct('2019-02-01'), color = "black", alpha = .5, size - .8) + | |
geom_text(aes(x = as.POSIXct('2019-02-01'), y = 40, angle = 90, vjust = -.1), label = 'Promotion', nudge_x = -60) + | |
labs(x = "Week", y = "Total Hours in Meetings", title = "Total Number of Hours Spent in Meetings") | |
ggsave("brett-work-hours.png", plot = graph, width = 15, height = 10, units = "cm", scale = 1) | |
table %>% filter(date <= as.Date("2019-02-01")) %>% pull(total_hours) %>% as.numeric() %>% mean(trim = .1) | |
table %>% filter(date >= as.Date("2019-02-01")) %>% pull(total_hours) %>% as.numeric() %>% mean(trim = .1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment