day_to_num: Convert the days of the week to numeric

View source: R/day_to_num.R

day_to_numR Documentation

Convert the days of the week to numeric

Description

day_to_num converts the days of the week from character format into numeric format for use in n_day.

Usage

day_to_num(x, ignore_case = TRUE)

Arguments

x

A character string containing days of the week in full (e.g. "Friday") or abbreviated (e.g. "Fri") form.

ignore_case

Logical. If TRUE, the case of x is ignored. If FALSE, the case of x is preserved. If FALSE, days must be provided in full (e.g. "Friday") or three-character abbreviated (e.g. "Fri") form with only the first letter capitalised to be recognised as valid days of the week. Defaults to TRUE.

Details

The Date and POSIXt classes within R treat Sunday as day 0 in a week, and Saturday as day 6. day_to_num also treats Sunday as day 0 (as opposed to day 7) for the sake of consistency.

See Also

days_of_week for returning a vector of the days of the week.

weekdays for converting a date into the day of the week.

n_day for calculating the number of occurrences of a day of the week in a set time period.

Examples

day_to_num(c("Monday", "Tuesday", "Wed"))
day_to_num(days_of_week())
day_to_num(weekdays(lubridate::dmy(01012020)))


jackhannah95/jafun documentation built on Feb. 9, 2023, 12:24 p.m.