--- 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 and time functions for public health surveillance. Its main purpose is consistent conversion between: - Date. - Isoyear, isoweek, isoyearweek. - Season week. It also provides functions to generate rolling date ranges for computing weekly, bi-weekly, and 4-week averages. `cstime` is part of the [csverse](https://niphr.github.io/packages.html) package suite. ```{r setup} library(cstime) library(magrittr) ``` ## Date to isoyear ```{r} date_to_isoyear_c('2021-01-01') ``` ## Isoyearweek string to isoyear and isoweek ```{r} isoyearweek_to_isoyear_c("2021-02") isoyearweek_to_isoweek_c("2021-02") ``` ## Season week and isoweek ```{r} seasonweek_to_isoweek_n(10) isoweek_to_seasonweek_n(1) ```