library(ggplot2) library(ggalluvial) library(tidyverse) data <- read_delim("erasmus.csv", delim=";") names(data) <- c("Project Reference", "Academic Year", "Mobility Start Month", "Mobility End Month", "Mobility Duration", "Activity (mob)", "Field of Education", "Participant Nationality", "Education Level", "Participant Gender", "Participant Profile", "Special Needs", "Fewer Opportunities", "GroupLeader", "Participant Age", "Sending Country Code", "Sending City", "Sending Organization", "Sending Organisation Erasmus Code", "Receiving Country Code", "Receiving City", "Receiving Organization", "Receiving Organisation Erasmus Code", "Participants") df <- data.frame(gender = c(data$`Participant Gender`), mobility_start_month = c(data$`Mobility Start Month`), status = c(data$`Participant Profile`)) df <- filter(df, gender != "Undefined") df <- df %>% group_by(gender, mobility_start_month, status) %>% tally() df g <- ggplot(df, aes(y = n, axis1 = gender, axis2 = mobility_start_month)) + geom_alluvium(aes(fill = status), width = 1/12) + geom_stratum(width = 1/12, fill = "black", color = "grey") + geom_label(stat = "stratum", aes(label = after_stat(stratum))) + scale_x_discrete(limits = c("Gender", "Month"), expand = c(.05, .05)) + scale_fill_brewer(type = "div", palette = "RdYlGn") + ylab("Number of Participants") g