I have been using code that is verbatim to that in: https://www.r-bloggers.com/2022/10/how-to-create-a-ggalluvial-plot-in-r/ in order to produce an alluvial plot. While I can get the plot to appear:
My Code:
#install.packages("ggalluvial")
library(ggalluvial)
ggplot(data = Sankey_Table, aes(axis1 = source, axis2 = target, y = value)) +
geom_alluvium(aes(fill = source)) +
ggalluvial::geom_stratum(alpha = 0.5, na.rm = TRUE) +
geom_text(stat = "stratum", aes(label = after_stat(stratum))) +
scale_x_discrete(limits = c("Source", "Target"),
expand = c(0.15, 0.05)) +
theme_void()
My Data:
> head(Sankey_Table)
# A tibble: 6 × 5
source target value
<chr> <chr> <dbl>
1 pre :: H0 post :: H0 31
2 pre :: H0 post :: Hlow 11
3 pre :: H0 post :: pCR 12
4 pre :: H0 post :: NA 1
5 pre :: Hlow post :: H0 28
6 pre :: Hlow post :: Hlow 29
When I run the above code, I get this error message and the following image:
Warning messages:
1: Computation failed in `stat_stratum()`:
unused argument (na_rm = na_rm)
2: Computation failed in `stat_stratum()`:
unused argument (na_rm = na_rm)
I have no idea why the labels are not appearing as they do on the reference website, using essentially the same code and a dataframe formatted the exact same way. I have been having some difficulty getting labels to appear with ggsankey as well using the geom_text function and have been at a loss as to what to do. I've tried re-installing the ggplot2 and alluvial packages, and changing around the argument order to just about every combination I can think of.
Any help would be enormously appreciated.
I am expecting something to the effect of: enter image description here
The above plot was generated using the exact same code (link is above).