How does the formula in the first parameter of boxplot in the following code make the correct correspondence between b and a after a has been reordered.
a <- as.factor(c("TX", "NY", "WA"))
levels(a)
b <- c(5, 3, 2)
boxplot(b ~ a)
# Order the levels of a according to their value in b
a_reordered <- reorder(a, b)
levels(a_reordered)
boxplot(b ~ a_reordered)
Why doesn't b need to be reordered as well?
edit: I replaced my example with the concrete example of @Marius