Learn R Programming

plgraphics (version 1.2)

weekday: Get Day of Week or Year, Month, Day

Description

From Dates, obtain the day of the week or the year, month and day

Usage

weekday(date, month = NULL, day = NULL, out = NULL, factor = FALSE)
ymd(date)

Value

For weekdays, the output is as described above, depending on

factor and out.

Arguments

date

date(s), given as a Date object, a character object that can be converted into a Date, or as julian, or the year, in which case month and day must be given.

month, day

If the first argument is the year, these arguments must also be given.

factor

logical: Should the result be a (ordered) factor?

out

selection of output: either "numeric" for numeric output (0 for Sunday, ... 6 for Saturday), "full" or "long" for full weekday names, or "short" for abbreviated (3 character) names. Defaults to "full" if factor is TRUE, to "numeric" otherwise.

Author

Werner A. Stahel

See Also

day.of.week, month.day.year

Examples

Run this code
weekday(c("2020-05-01", "2020-05-02"), factor=TRUE)
## [1] Thursday Sunday  
## Levels: Sunday < Monday < Tuesday < Wednesday < Thursday < Friday < Saturday

dt <- ymd(18100+1:5)
weekday(dt)
## [1] 3 4 5 6 0

Run the code above in your browser using DataLab