R语言 确定一个特定日期的工作日 – weekdays() 函数
R语言中的 weekdays() 函数用于确定作为参数传递给它的特定日期上的工作日。
语法: weekdays(date, abbreviate)
参数:
date: 要检查的日期
abbreviate: 缩写工作日的布尔值
例子1 :
# R program to find the weekday
# on a specific date
# Specifying the date
date <- as.POSIXlt("2020-06-23")
date
# Calling weekdays() function
weekdays(date)
输出
[1] "2020-06-23 UTC"
[1] "Tuesday"
例2 :
# R program to find the weekday
# on a specific date
# Specifying the date
date <- as.POSIXlt("1994-06-17")
date
# Calling weekdays() function
weekdays(date, abbreviate = TRUE)
输出
[1] "1994-06-17 UTC"
[1] "Fri"