fill_dates: Ensure that all units of observation have all dates within...

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Ensure that all units of observation have all dates within the max and min of the date variable.

Usage

1
fill_dates(df, grouping_vars, date_var)

Arguments

df

the data.frame to fill in

grouping_vars

a character vector with the variable names that define the grouping structure that will uniquely identify the relavant units of observation

date_var

Value

the same data.frame with any required dates filled in for each unit. Variables without grouping_vars will be missing.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(123)
tmp <- tibble(County = sample(LETTERS[1:3], 15, replace = TRUE),
              Date = sample(seq(as.Date("2020-07-01"), as.Date("2020-07-07"), by = 1),
                            15, replace = TRUE)) %>%
  distinct(.) %>%
  arrange(County, Date)

#Compare

tmp

#To

arrange(fill_dates(tmp, grouping_vars = "County", date_var = "Date"),
        County, Date)

Skomim/COVID_trajectory_Madison documentation built on July 19, 2020, 12:34 a.m.