Skip to contents

Extract metadata from raw data, either by reference or by report date. For the target date chosen (reference or report), confirm, max_confirm``, and cum_prop_reported` are dropped and the first observation for each group and date is retained.

Usage

enw_metadata(obs, target_date = c("reference_date", "report_date"))

Arguments

obs

A data.frame or data.table with columns: reference_date and/or report_date; at least one must be provided, .group, a grouping column and a date, a Date column.

target_date

A character string, either "reference_date" or "report_date". The column corresponding to this string will be used as the target date for metadata extraction.

Value

A data.table with columns:

  • date, a Date column

  • .group, a grouping column

and the first observation for each group and date. The data.table is sorted by .group and date.

Examples

obs <- data.frame(
 reference_date = as.Date("2021-01-01"),
 report_date = as.Date("2022-01-01"), x = 1:10
)
enw_metadata(obs, target_date = "reference_date")
#>          date .group x
#> 1: 2021-01-01      1 1