Created
November 26, 2019 11:00
-
-
Save timcdlucas/341ff9ce04af930af30acbd6612bd4de to your computer and use it in GitHub Desktop.
Use fct_reorder in facet_wrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(forcats) | |
library(ggplot2) | |
ggplot(mtcars, aes(x = disp, y = mpg)) + | |
geom_point() + | |
facet_wrap(~ factor(gear)) | |
ggplot(mtcars, aes(x = disp, y = mpg)) + | |
geom_point() + | |
facet_wrap(~ fct_reorder(factor(gear), disp)) | |
ggplot(mtcars, aes(x = disp, y = mpg)) + | |
geom_point() + | |
facet_wrap(~ fct_reorder(factor(gear), disp, .fun = length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment