Learn R Programming

ds4psy (version 0.4.0)

what_day: What day (of the week) is it?

Description

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

Usage

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

Arguments

when

Date (as a scalar or vector). Default: when = Sys.Date(). Using as.Date(when) to convert strings into dates if a different when is provided.

abbr

Boolean: Return abbreviated? Default: abbr = FALSE.

Details

what_day returns 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(), is_leap_year(), what_date(), what_month(), what_time(), what_week(), what_year()

Examples

Run this code
# NOT RUN {
what_day()
what_day(abbr = TRUE)

what_day(when = Sys.time())  # with POSIXct time

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

# with time vector (strings of POSIXct times):
ts <- c("2020-12-25 10:11:12 CET", "2020-12-31 23:59:59")
what_day(ts)

# }

Run the code above in your browser using DataLab