month_fct: Create a month factor column

View source: R/month_fct.R

month_fctR Documentation

Create a month factor column

Description

Returns the month abbreviations (Jan, Feb, ...) as a factor (so to keep the annual order), with the option to define the first month (as factor level), so also hydrological years are possible (Oct, Nov, Dec, Jan, ..). Requires a numeric input vector of months.

Usage

month_fct(month, first_month = 1)

Arguments

month

a vector of months (numeric)

first_month

numeric, month which should be the first level (default: 1, i.e. Jan)

Value

Factor of same length as input.

Examples


month <- sample(1:12, 30, replace = TRUE)
month
month_fct(month)
month_fct(month, 10) # note the level order


mitmat/mitmatmisc documentation built on Aug. 22, 2024, 3:28 a.m.