Issue with a "Computation failed in `stat_stratum()`"

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!

If someone could help me please? :slight_smile:

1 Like

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.

1 Like

Hi
Here I am also having the same issue with stat_stratum. Do you have any idea or solution for it?
Thanks a lot!

1 Like

Hi, welrome to the forum.

Please see my response to djedje.

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.

1 Like

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 :slight_smile:
Thank you all
Jérome

  • data that, if I understand correctly, everyone have*

So we do! I had never seen it used before but UCBAdmissions is a table in the package ‘datasets’.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.