epix_fill_through_version: Fill 'epi_archive' unobserved history

View source: R/methods-epi_archive.R

epix_fill_through_versionR Documentation

Fill epi_archive unobserved history

Description

This function fills in missing version history in an epi_archive object up to a specified version, updating the versions_end field as necessary. Note that the filling is done in a compactified way, see details.

Usage

epix_fill_through_version(x, fill_versions_end, how = c("na", "locf"))

Arguments

x

An epi_archive

fill_versions_end

a scalar of the same class&type as x$version: the version through which to fill in missing version history; the epi_archive's versions_end attribute will be set to this, unless it already had a later ⁠$versions_end⁠.

how

Optional; "na" or "locf": "na" fills missing version history with NAs, "locf" fills missing version history with the last version of each observation carried forward (LOCF). Default is "na".

Details

Note that we generally store epi_archive's in a compacted form, meaning that, implciitly, if a version does not exist, but the version_end attribute is greater, then it is understood that all the versions in between had the same value as the last observed version. This affects the behavior of this function in the following ways:

  • if how = "na", then the function will fill in at most one missing version with NA and the rest will be implicit.

  • if how = "locf", then the function will not fill any values.

Value

An epi_archive

An epi_archive

Examples

test_date <- as.Date("2020-01-01")
ea_orig <- as_epi_archive(data.table::data.table(
  geo_value = "ak",
  time_value = test_date + c(rep(0L, 5L), 1L),
  version = test_date + c(1:5, 2L),
  value = 1:6
))
epix_fill_through_version(ea_orig, test_date + 8, "na")
epix_fill_through_version(ea_orig, test_date + 8, "locf")

cmu-delphi/epiprocess documentation built on Oct. 29, 2024, 5:37 p.m.