Learn R Programming

clock (version 0.7.1)

weekday_code: Extract underlying weekday codes

Description

weekday_code() extracts out the integer code for the weekday.

Usage

weekday_code(x, ..., encoding = "western")

Value

An integer vector of codes.

Arguments

x

[weekday]

A weekday vector.

...

These dots are for future extensions and must be empty.

encoding

[character(1)]

One of:

  • "western": Encode weekdays assuming 1 == Sunday and 7 == Saturday.

  • "iso": Encode weekdays assuming 1 == Monday and 7 == Sunday. This is in line with the ISO standard.

Examples

Run this code
# Here we supply a western encoding to `weekday()`
x <- weekday(1:7)
x

# We can extract out the codes using different encodings
weekday_code(x, encoding = "western")
weekday_code(x, encoding = "iso")

Run the code above in your browser using DataLab