I don't understand how I can change the levels order of the fill variable in R waffle::geom_waffle().
It seems that sorting the variable is ineffective since it's always sorted by the number of observations.
# First example
db_graph <- data.table::data.table(group = c("A", "B"),
n = c(13, 25))
ggplot2::ggplot(data = db_graph,
mapping = ggplot2::aes(fill = group,
values = n)) +
waffle::geom_waffle(flip = TRUE)
# Second example
db_graph <- db_graph[j = group := forcats::fct_rev(group)]
ggplot2::ggplot(data = db_graph,
mapping = ggplot2::aes(fill = group,
values = n)) +
waffle::geom_waffle(flip = TRUE)