(Copy-pasted from the drlib
package)
Reorder a column before plotting with faceting, such that the values are ordered
within each facet. This requires two functions: reorder_within
applied to
the column, then either scale_x_reordered
or scale_y_reordered
added
to the plot.
This is implemented as a bit of a hack: it appends ___ and then the facet
at the end of each string.
reorder_within(x, by, within, fun = mean, sep = "___", ...) scale_x_reordered(..., sep = "___") scale_y_reordered(..., sep = "___")
x | Vector to reorder. |
---|---|
by | Vector of the same length, to use for reordering. |
within | Vector of the same length that will later be used for faceting |
fun | Function to perform within each subset to determine the resulting ordering. By default, mean. |
sep | Separator to distinguish the two. You may want to set this manually if ___ can exist within one of your labels. |
... | In |
https://github.com/dgrtwo/drlib/blob/master/R/reorder_within.R#L1
None.