How to force specific order of the variables in a waffle chart in R?

138 Views Asked by At

please do forgive me for potentially asking a really silly question but its really important that the data I am representing in my waffle chart is ordered according to the input of my vector.

I am really struggling to force the graph to not reorder into descending order. Any feedback is welcome.

library(waffle)
x <- c(A = 5, B = 5, C  = 2, D = 3)
waffle(x, rows=5)

Obviously the code above is super basic but I am actually learning this from 0 due to the purpose of the code.

Thanks in advance!

1

There are 1 best solutions below

1
Quinten On

If you change the rows = 3, it will be in the right order:

library(waffle)
x <- c(A = 5, B = 5, C  = 2, D = 3)
waffle(x, rows = 3)

Created on 2022-08-15 by the reprex package (v2.0.1)