order_season_levels: Order season levels

View source: R/seasons.R

order_season_levelsR Documentation

Order season levels

Description

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

Usage

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))
# nice ordered plot
qplot(season, n, fill = season, data = ordered_seasons, geom = "col")


StatisticsNZ/er.helpers documentation built on Oct. 2, 2023, 7:24 a.m.