Description Usage Arguments Value Functions Examples
Create a date from year and week variable columns
1 | cdc_yearweek_to_date(data, year_integer, week_integer)
|
data |
input dataset |
year_integer |
year column variable as integer |
week_integer |
week column variable as integer |
html table
cdc_yearweek_to_date
:
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.