Closed batpigandme closed 1 year ago
Counter argument to myself. This is already there in weekday_factor()
, so maybe it's not necessary.
weekdays <- clock::weekday(1:7)
clock::weekday_factor(weekdays)
#> [1] Sun Mon Tue Wed Thu Fri Sat
#> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
clock::weekday_factor(weekdays, abbreviate = FALSE)
#> [1] Sunday Monday Tuesday Wednesday Thursday Friday Saturday
#> 7 Levels: Sunday < Monday < Tuesday < Wednesday < Thursday < ... < Saturday
Created on 2023-04-03 with reprex v2.0.2
Yea and I think most users should use the high-level API function, date_weekday_factor()
, where the input is Date and the output is an ordered factor (i.e. base R types only)
library(clock)
x <- as.Date("2023-05-01") + 0:3
date_weekday_factor(x)
#> [1] Mon Tue Wed Thu
#> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
Most of the time the high-level API should be sufficient, i.e. anything with date_*()
Yeah, makes sense. IDK how I got sidetracked into weekday()
world.
Most of the time we want weekdays to be abbreviated, but it'd be nice if there was an argument for
as_weekday()
and/orweekday()
that allowed you to print the full name of the day, like withabbr
inlubridate::wday()
, especially since the full name of weekdays are used withclock_weekdays
(at least in the examples).Created on 2023-04-03 with reprex v2.0.2 I think the argument,
abbreviate
, is already there in the underlying functions, e.g. https://github.com/r-lib/clock/blob/64c1a53a7df0b3f4c04555a03a6472450f8745ce/R/weekday.R#L121 but it can't be sent intoas_weekday()
.