1ggplot(df_data_Aluv,
2 aes(x = month,
3 stratum = Job,
4 alluvium = Employee,
5 y = freq,
6 fill = Job,
7 label = Job)) +
8 scale_x_discrete(expand = c(.1, .1)) +
9 geom_flow(stat = "alluvium",
10 lode.guidance = "frontback",
11 color = "darkgray") +
12 geom_stratum(alpha = .5) +
13 geom_text(stat = "stratum", size = 3) +
14 theme(legend.position = "bottom") +
15 ggtitle("Project month responses at three points in time")
1 df_data_Aluv <- data %>%
2 filter(PostDate >= "2019-08-01" & PostDate <= "2019-10-30") %>%
3 select(date = PostDate, Employee, Job, Hours) %>%
4 group_by(Job, month = as.character(floor_date(date, "month")), Employee) %>%
5 summarize(freq = n_distinct(Employee), Hours = sum(Hours)) %>%
6 mutate(empmon = paste(Employee, " -- ", month)) %>%
7 group_by(empmon) %>%
8 filter(Hours == max(Hours)) %>%
9 distinct(empmon, .keep_all = TRUE)