Intro to cstime

Chi Zhang

2021-09-15

cstime provides date time functions for public health purposes.

The core functionality is consistent time conversion between :

It also provides functions to generate rolling dates for computing the weekly, bi-weekly, 4 week averages.

cstime is part of the csverse package suite.

library(cstime)
#> cstime 2023.5.3
#> https://www.csids.no/cstime/
library(magrittr)

To convert a date to isoyear:

date_to_isoyear_c('2021-01-01')
#> [1] "2020"

To convert a isoyearweek string to isoyear/isoweek:

isoyearweek_to_isoyear_c("2021-02")
#> [1] "2021"
isoyearweek_to_isoweek_c("2021-02")
#> [1] "02"

To convert a season week to isoweek (and reverse):

seasonweek_to_isoweek_n(10)
#> [1] 10
isoweek_to_seasonweek_n(1)  
#> [1] 24