Season week

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Season week (i.e. the week number within a season) conversion is used for certain outcomes of interest, such as influenza. It is frequently used for plotting purposes.

Isoweek can be integers between 1 and 53. Season week can be integers between 1 and 52. When isoweek is 53, season week is 23.5.

library(cstime)
library(magrittr)
library(data.table)
library(ggplot2)
pd <- data.table(isoweek = 1:53, seasonweek = isoweek_to_seasonweek_n(1:53))
q <- ggplot(pd, aes(x=seasonweek, y = isoweek))
q <- q + geom_point()
q <- q + geom_point(data = pd[isoweek==53], mapping = aes(color="Isoweek==53"))
q <- q + scale_color_discrete(NULL)
q <- q + scale_x_continuous("seasonweek", breaks = seq(1,52,4))
q <- q + scale_y_continuous("isoweek", breaks = seq(1,53,4))
q
seasonweek_to_isoweek_c(10)
seasonweek_to_isoweek_n(10)
isoweek_to_seasonweek_n(1)
seasonweek_to_isoweek_n(1:52)
isoweek_to_seasonweek_n(1:53)


Try the cstime package in your browser

Any scripts or data that you put into this service are public.

cstime documentation built on May 31, 2023, 9:27 p.m.