Hi there!
I try to make an alluvial diagram in ggplot2 but I encounter an issue trying to use geom_stratum().
For instance, if I try with this:
ggplot(as.data.frame(UCBAdmissions),
aes(y = Freq, axis1 = Gender, axis2 = Dept)) +
geom_alluvium(aes(fill = Admit), 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", "Dept"), expand = c(.05, .05)) +
scale_fill_brewer(type = "qual", palette = "Set1") +
ggtitle("UC Berkeley admissions and rejections, by sex and department")
I get :
Warning messages:
1: Computation failed in stat_stratum()
Caused by error in nth():
! unused argument (na_rm = na_rm)
2: Computation failed in stat_stratum()
Caused by error in nth():
! unused argument (na_rm = na_rm)
with an output plot where alluvial flows are fine but without stratus labels!
I think we nee to see a reprex and some sample data.
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.
Without some idea of what packages (libraries) you are using and what your data looks like, and any errors you are getting it is pretty hard to offer any help.
Hi there! thank you for your answers.
Actually, the sample I picked it up use data that, if I understand correctly, everyone have (copy/paste what I wrote).
In any case, I fixed the error with the update of all packages! It works fine now
Thank you all
Jérome