Learn R Programming

ds4psy (version 0.2.0)

what_day: What day is it?

Description

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

Usage

what_day(when = Sys.time(), unit = "week", abbr = FALSE, as_integer = FALSE)

Arguments

when

Date (as a scalar or vector). Default: when = NA. Using as.Date(when) to convert strings into dates, and Sys.Date(), if when = NA.

unit

Character: Unit of day? Possible values are "week", "month", "year". Default: unit = "week" (for day within week).

abbr

Boolean: Return abbreviated? Default: abbr = FALSE.

as_integer

Boolean: Return as integer? Default: as_integer = FALSE.

Details

what_day returns the day of when or Sys.Date() (as a name or number).

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: cur_date(), cur_time(), what_date(), what_month(), what_time(), what_week(), what_year()

Examples

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

# Work with vectors (when as characters):
ds <- c("2020-01-01", "2020-02-29", "2020-12-24", "2020-12-31")
what_day(when = ds)
what_day(when = ds, unit = "month", as_integer = TRUE)
what_day(when = ds, unit = "year", as_integer = TRUE)

 
# }

Run the code above in your browser using DataLab