what_wday: What day of the week is it?

View source: R/time_fun.R

what_wdayR Documentation

What day of the week is it?

Description

what_wday provides a satisficing version of to determine the day of the week corresponding to a given date.

Usage

what_wday(when = Sys.Date(), abbr = FALSE)

Arguments

when

Date (as a scalar or vector). Default: when = Sys.Date(). Aiming to convert when into "Date" if a different object class is provided.

abbr

Boolean: Return abbreviated? Default: abbr = FALSE.

Details

what_wday returns the name of the weekday of when or of Sys.Date() (as a character string).

See Also

what_date() function to obtain dates; what_time() function to obtain times; cur_time() function to print the current time; cur_date() function to print the current date; now() function of the lubridate package; Sys.time() function of base R.

Other date and time functions: change_time(), change_tz(), cur_date(), cur_time(), days_in_month(), diff_dates(), diff_times(), diff_tz(), is_leap_year(), what_date(), what_month(), what_time(), what_week(), what_year(), zodiac()

Examples

what_wday()
what_wday(abbr = TRUE)

what_wday(Sys.Date() + -1:1)  # Date (as vector)
what_wday(Sys.time())         # POSIXct
what_wday("2020-02-29")       # string (of valid date)
what_wday(20200229)           # number (of valid date)

# date vector (as characters):
ds <- c("2020-01-01", "2020-02-29", "2020-12-24", "2020-12-31")
what_wday(when = ds)
what_wday(when = ds, abbr = TRUE)

# time vector (strings of POSIXct times):
ts <- c("1969-07-13 13:53 CET", "2020-12-31 23:59:59")
what_wday(ts)

# fame data:
greta_dob <- as.Date(fame[grep(fame$name, pattern = "Greta") , ]$DOB, "%B %d, %Y")
what_wday(greta_dob)  # Friday, of course.


ds4psy documentation built on Sept. 15, 2023, 9:08 a.m.