order_season_levels | R Documentation |
Standardise season as a factor with ordered seasons. If an "annual" category is present it includes at the end of the other seasons. Season names are converted to sentence case
order_season_levels(x)
x |
character vector. If a factor will be coerced to character first |
a factor with ordered levels for season
library(ggplot2)
library(tibble)
seasons <- tribble(
~ season, ~n,
"autum", 1,
"summer", 2,
"winter", 3,
"spring", 1,
"annual", 2)
# unordered ugly plot
qplot(season, n, fill = season, data = seasons, geom = "col")
ordered_seasons <- dplyr::mutate(seasons,
season = order_season_levels(season))
# nice ordered plot
qplot(season, n, fill = season, data = ordered_seasons, geom = "col")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.