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

weekdayR Documentation

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)

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.

Value

For weekdays, the output is as described above, depending on factor and out.

Note

The functions call functions from the chron package

Author(s)

Werner A. Stahel

See Also

day.of.week, month.day.year

Examples

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

plgraphics documentation built on Oct. 19, 2023, 3 p.m.