cdc_yearweek_to_date: Time related function

Description Usage Arguments Value Functions Examples

View source: R/cdc_time.R

Description

Create a date from year and week variable columns

Usage

1
cdc_yearweek_to_date(data, year_integer, week_integer)

Arguments

data

input dataset

year_integer

year column variable as integer

week_integer

week column variable as integer

Value

html table

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(tidyverse)
library(lubridate)
library(aweek)
data_ts <- tibble(date=seq(ymd('2012-04-07'),
                           ymd('2012-04-22'),
                           by = '5 day')) %>%
  mutate(#value = rnorm(n(),mean = 5),
    #using aweek
    epiweek_d = date2week(date, week_start = "Sunday"),
    epiweek_w = date2week(date, week_start = "Sunday", floor_day = TRUE),
    #using lubridate
    epiweek_n = epiweek(date),
    day_of_week = wday(date,label = T,abbr = F),
    month = month(date,label = F,abbr = F),
    year = year(date)) %>%
  print()

data_ts %>%
  # use the function
  cdc_yearweek_to_date(year_integer = year,
                       week_integer = epiweek_n)

avallecam/cdcper documentation built on Dec. 19, 2021, 5:46 a.m.