My goal is to order the boxes in a lattice bwplot by their median. I know that aggregate, reorder, etc., as well as the lattice index.cond or perm.cond parameters can be used for this this purpose, but I struggle putting the pieces correctly together with bwplot. I would appreciate an answer that gives a clean and reusable solution, and states some details about how the parameters and functions work together in that solution - because this is what is don't fully understand right now.
This is a minimal working example of the plot without ordering:
bwplot(data = iris, x = Sepal.Width ~ Species)
To my understanding, ordering the boxes by the median could be enforced by something similar to this:
# notrun
bwplot(data = iris, x = Sepal.Width ~ Species | XXX, index.cond = function(x,y) reorder(x,y,median))
bwplot(data = iris, x = Sepal.Width ~ Species, perm.cond = XXX)
PS: the bunch of existing questions on SO related to ordering a bwplot (at least those I found) either investigate other details, or did not lead to a generic solution for me.
