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