Relative Content

Tag Archive for rggplot2dplyrtibble

In R while using facet_grid function, how to keep the axis variable order same, not to reaarrange according to variable use in facet_grid

library(ggplot2) library(tibble) data(mtcars) my_mtcars <- mtcars %>% tibble::rownames_to_column(var = “car”) %>% dplyr::select(car,mpg,wt, gear) p1 <- ggplot2::ggplot(my_mtcars, ggplot2::aes(x = mpg, y = car )) + ggplot2::geom_point() p2 <- p1 + ggplot2::facet_grid(gear ~ . , scales = “free”, space = “free”, switch = “y”) Issue: In p2, “car” (y-axis) variable is re-arranged according to “gear” order (e.g. […]