Skip to contents

Utilities for working with academic years

Usage

academic_year(
  x = integer(),
  boundary = getOption("acadyr.academic_year_boundary", as.Date("2020-09-01"))
)

is_academic_year(x)

as_academic_year(
  x,
  boundary = getOption("acadyr.academic_year_boundary", as.Date("2020-09-01")),
  ...
)

Arguments

x
  • For academic_year(): A numeric vector

  • For as_academic_year(): An object to coerce

  • For is_academic_year(): An object to test

boundary

A boundary date where the new academic year should begin. Note that only the month/day of this date is used. This can be set using the global option acadyr.academic_year_boundary. E.g. to use academic years starting on August 1, use the following:

options(acadyr.academic_year_boundary = as.Date("2020-08-01"))

...

Passed on to methods

  • For academic_year(): A <financial_year> vector

  • For as_academic_year(): A <financial_year> vector

  • For is_academic_year(): A <logical> vector

Details

Note that many countries use a slightly different academic year start date each year, meaning that most use-cases for these utilities will necessitate some approximation.

Examples

# Numbers are treated as if they represent years
academic_year(2005:2015)
#> <academic_year[11]>
#>  [1] 2005/06 2006/07 2007/08 2008/09 2009/10 2010/11 2011/12 2012/13 2013/14
#> [10] 2014/15 2015/16

# Dates are mapped to the year they fall within
dates <- as.Date(c("2020-08-01", "2020-09-01"))
academic_year(dates)
#> <academic_year[2]>
#> [1] 2019/20 2020/21

# The year they fall within depends on the year boundary, which
# defaults to September 01
academic_year(dates, boundary = as.Date("2020-08-01"))
#> <academic_year[2]>
#> [1] 2020/21 2020/21

# as_academic_year() also understands character vectors:
as_academic_year(c("2020/21", "2021/22"))
#> <academic_year[2]>
#> [1] 2020/21 2021/22