--- title: "Intro to cstime" output: rmarkdown::html_vignette author: "Chi Zhang" date: "2021-09-15" vignette: > %\VignetteIndexEntry{Intro to cstime} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} editor_options: chunk_output_type: console --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` `cstime` provides date time functions for public health purposes. The core functionality is consistent time conversion between : - Date. - Isoyear, isoweek, isoyearweek. - Season week. It also provides functions to generate rolling dates for computing the weekly, bi-weekly, 4 week averages. `cstime` is part of the [csverse](https://www.csids.no/packages.html) package suite. ```{r setup} library(cstime) library(magrittr) ``` To convert a date to isoyear: ```{r} date_to_isoyear_c('2021-01-01') ``` To convert a isoyearweek string to isoyear/isoweek: ```{r} isoyearweek_to_isoyear_c("2021-02") isoyearweek_to_isoweek_c("2021-02") ``` To convert a season week to isoweek (and reverse): ```{r} seasonweek_to_isoweek_n(10) isoweek_to_seasonweek_n(1) ```