date_month_factor: Convert a date or date-time to an ordered factor of month...

View source: R/date.R

date_month_factorR Documentation

Convert a date or date-time to an ordered factor of month names

Description

date_month_factor() extracts the month values from a date or date-time and converts them to an ordered factor of month names. This can be useful in combination with ggplot2, or for modeling.

Usage

date_month_factor(x, ..., labels = "en", abbreviate = FALSE)

Arguments

x

⁠[Date / POSIXct / POSIXlt]⁠

A date or date-time vector.

...

These dots are for future extensions and must be empty.

labels

⁠[clock_labels / character(1)]⁠

Character representations of localized weekday names, month names, and AM/PM names. Either the language code as string (passed on to clock_labels_lookup()), or an object created by clock_labels().

abbreviate

⁠[logical(1)]⁠

If TRUE, the abbreviated month names from labels will be used.

If FALSE, the full month names from labels will be used.

Value

An ordered factor representing the months.

Examples

x <- add_months(as.Date("2019-01-01"), 0:11)

date_month_factor(x)
date_month_factor(x, abbreviate = TRUE)
date_month_factor(x, labels = "fr")

clock documentation built on Sept. 11, 2024, 8:39 p.m.