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)

Arguments

x

character vector. If a factor will be coerced to character first

Value

a factor with ordered levels for season

Examples

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))
#> Warning: Autum not recognised as valid season name(s)
# nice ordered plot qplot(season, n, fill = season, data = ordered_seasons, geom = "col")