weekday_code()
extracts out the integer code for the weekday.
Arguments
- x
[weekday]
A weekday vector.
- ...
These dots are for future extensions and must be empty.
- encoding
[character(1)]
One of:
"western"
: Encode weekdays assuming1 == Sunday
and7 == Saturday
."iso"
: Encode weekdays assuming1 == Monday
and7 == Sunday
. This is in line with the ISO standard.
Examples
# Here we supply a western encoding to `weekday()`
x <- weekday(1:7)
x
#> <weekday[7]>
#> [1] Sun Mon Tue Wed Thu Fri Sat
# We can extract out the codes using different encodings
weekday_code(x, encoding = "western")
#> [1] 1 2 3 4 5 6 7
weekday_code(x, encoding = "iso")
#> [1] 7 1 2 3 4 5 6