Estoy intentando ordenar los estratos de un plot alluvial pero no puedo. Intento darles un nivel pero sigue saliendo la misma escala
dput(ggplot_alluvial_PHQ9)
structure(list(Var_tiempo = structure(c(1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 5L), levels = c("0 Months Baseline",
"3 Months using ETI", "6 Months using ETI", "9 Months using ETI",
"12 Months using ETI"), class = "factor"), values = structure(c(1L,
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
1L, 2L, 3L, 5L), levels = c("Normal", "Mild", "Moderate", "Moderately severe",
"Severe"), class = "factor"), per = c(63.2075471698113, 23.5849056603774,
11.3207547169811, 0.943396226415094, 0.943396226415094, 70.1754385964912,
22.8070175438597, 3.50877192982456, 3.50877192982456, 69.4736842105263,
23.1578947368421, 4.21052631578947, 1.05263157894737, 2.10526315789474,
78.6885245901639, 13.1147540983607, 8.19672131147541, 66.6666666666667,
24.7311827956989, 7.52688172043011, 1.0752688172043)), row.names = c(NA,
-21L), class = c("tbl_df", "tbl", "data.frame"))
ggplot_alluvial_PHQ9 %>%
mutate(values=factor(values,
levels = c("Normal",
"Mild",
"Moderate",
"Moderately severe",
"Severe")))->ggplot_alluvial_PHQ9
ggplot(ggplot_alluvial_PHQ9,
aes(x = Var_tiempo,
stratum=paste0(values,sprintf("\n%0.1f",round(per, digits = 1)), "%"),
# stratum=round(per, digits = 3),
alluvium = values,
y = per,
fill = values, label = values)) +
scale_x_discrete(expand = c(.1, 0)) +
geom_flow(width = 1/4, aes.flow = "backward") +
geom_stratum(alpha = .5, width = 1/4, position = "identity") +
geom_text(stat = "stratum", aes(label = after_stat(stratum)),size = 3,discern=FALSE)+
labs(x="",y="")+
guides(fill = guide_legend(title = NULL)) +
theme(legend.position = "none")->plot3;plot3
¿Cómo puedo ordenarlas? Gracias de antemano