在 R 编程中确定特定日期所在的季度 - Quarters()函数
R 语言中的quarters()
函数用于确定作为参数传递给它的特定日期所在的季度。
Syntax: quarters(date)
Parameters:
date: Date to be checked
示例 1:
# R program to find the quarter
# of a specific date
# Specifying the date
date <- as.POSIXlt("2020-06-23")
date
# Calling quarters() function
quarters(date)
输出:
[1] "2020-06-23 UTC"
[1] "Q2"
示例 2:
# R program to find the quarter
# of a specific date
# Specifying the date
date <- as.POSIXlt("1994-01-17")
date
# Calling quarters() function
quarters(date)
输出:
[1] "1994-01-17 UTC"
[1] "Q1"