Skip to content

[Feature Request] A trimester class similar to yearquarter for academic terms. #316

@Steven314

Description

@Steven314

When dealing with data from academic institutions, I often find myself dealing with the three academic terms (or trimesters): fall, spring, and summer. I would find it useful if there was an option similar to yearquarter that allowed a cycle of 3 terms annually, rather than 4 quarters.

Something similar was brought up in {lubridate} in 2023: tidyverse/lubridate#1134, but never went anywhere. My reasoning for bringing it up here is to hopefully parallel the scale_*_yearquarter() functionality {tsibble} provides as well as the time series modeling in the rest of the tidyverts ecosystem.

I think the main advantage to having a new class over defining a four month interval would be in having a fiscal_start (or perhaps named academic_start) argument. That would allow the terms to be labelled according to their academic significance rather than their calendar names.
For instance, the institution I work for often defines the academic year beginning in the summer term (in May), so academic_start = 5 would be used.

Something like this:

tibble::tribble(
    ~calendar_year, ~month, ~academic_trimester,
    2025,           1,      '2025 T3',
    2025,           5,      '2026 T1',
    2025,           9,      '2026 T2'
) |> 
    dplyr::mutate(calendar_trimester = tsibble::make_yearmonth(calendar_year, month)) |> 
    tsibble::tsibble(index = calendar_trimester)
# # A tsibble: 3 x 4 [4M]
#   calendar_year month academic_trimester calendar_trimester
#           <dbl> <dbl> <chr>                           <mth>
# 1          2025     1 2025 T3                      2025 Jan
# 2          2025     5 2026 T1                      2025 May
# 3          2025     9 2026 T2                      2025 Sep

where the academic_trimester column would be of the class I'm proposing. In which case then, the index could be the academic trimester and the interval would be [1T].

I put together a start of what I'm looking for but I don't have it working yet: Steven314/tsibble ... yeartrimester.R, and a new trimester accessor: Steven314/tsibble ... trimester.R . I essentially copied the source for yearquarter and lubridate::quarter and adapted it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions