I am looking to format the value labels with "," separators, particularly on the stratums (bar columns) of Alluvial/ Sankey plot using R ggalluvial.
While similar answers were found on other charts, the same attempt has returned an error (notice the missing value labels and messed up flow connections):
library(ggplot2)
library(ggalluvial)
library(scales)
vaccinations$freq = vaccinations$freq * 1000
ggplot(vaccinations,
aes(x = survey, stratum = response, alluvium = subject,
y = freq,
fill = response, label = comma(freq))) +
scale_x_discrete(expand = c(.1, .1)) +
geom_flow() +
geom_stratum(alpha = .5) +
geom_text(stat = "stratum", size = 3) +
theme(legend.position = "bottom") +
ggtitle("vaccination survey responses at three points in time")
Warning message:
Removed 12 rows containing missing values (geom_text).