lubridate (version 1.3.1)

wday: Get/set days component of a date-time.

Description

Date-time must be a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, its, ti, jul, timeSeries, and fts objects.

Usage

wday(x, label = FALSE, abbr = TRUE)

Arguments

x
a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, its, ti, jul, timeSeries, or fts object.
label
logical. Only available for wday. TRUE will display the day of the week as a character string label such as "Sunday." FALSE will display the day of the week as a number.
abbr
logical. Only available for wday. FALSE will display the day of the week as a character string label such as "Sunday." TRUE will display an abbreviated version of the label, such as "Sun". abbr is disregarded if label = FALSE.

Value

  • wday returns the day of the week as a decimal number (01-07, Sunday is 1).

See Also

yday, mday

Examples

Run this code
x <- as.Date("2009-09-02")
wday(x) #4

wday(ymd(080101))
# 3
wday(ymd(080101), label = TRUE)
# "Tuesday"
wday(ymd(080101), label = TRUE, abbr = TRUE)
# "Tues"
wday(ymd(080101) + days(-2:4), label = TRUE, abbr = TRUE)
# "Sun"   "Mon"   "Tues"  "Wed"   "Thurs" "Fri"   "Sat"

Run the code above in your browser using DataCamp Workspace