date_weekday_factor {clock} | R Documentation |
date_weekday_factor()
converts a date or date-time to an ordered factor
with levels representing the weekday. This can be useful in combination with
ggplot2, or for modeling.
date_weekday_factor( x, ..., labels = "en", abbreviate = TRUE, encoding = "western" )
x |
A date or date-time vector. |
... |
These dots are for future extensions and must be empty. |
labels |
Character representations of localized weekday names, month names, and
AM/PM names. Either the language code as string (passed on to
|
abbreviate |
If If |
encoding |
One of:
|
An ordered factor representing the weekdays.
x <- as.Date("2019-01-01") + 0:6 # Default to Sunday -> Saturday date_weekday_factor(x) # ISO encoding is Monday -> Sunday date_weekday_factor(x, encoding = "iso") # With full names date_weekday_factor(x, abbreviate = FALSE) # Or a different language date_weekday_factor(x, labels = "fr")