epix_as_of: Generate a snapshot from an 'epi_archive' object

View source: R/methods-epi_archive.R

epix_as_ofR Documentation

Generate a snapshot from an epi_archive object

Description

Generates a snapshot in epi_df format from an epi_archive object, as of a given version. See the archive vignette for examples.

Usage

epix_as_of(
  x,
  version,
  min_time_value = -Inf,
  all_versions = FALSE,
  max_version = deprecated()
)

Arguments

x

An epi_archive object

version

Time value specifying the max version to permit in the snapshot. That is, the snapshot will comprise the unique rows of the current archive data that represent the most up-to-date signal values, as of the specified version (and whose time values are at least min_time_value.)

min_time_value

Time value specifying the min time value to permit in the snapshot. Default is -Inf, which effectively means that there is no minimum considered.

all_versions

If all_versions = TRUE, then the output will be in epi_archive format, and contain rows in the specified time_value range having version <= version. The resulting object will cover a potentially narrower version and time_value range than x, depending on user-provided arguments. Otherwise, there will be one row in the output for the version of each time_value. Default is FALSE.

max_version

[Deprecated] please use version argument instead.

Value

An epi_df object.

Examples

epix_as_of(
  archive_cases_dv_subset,
  version = max(archive_cases_dv_subset$DT$version)
)

range(archive_cases_dv_subset$DT$version) # 2020-06-02 -- 2021-12-01

epix_as_of(archive_cases_dv_subset, as.Date("2020-06-12"))

# --- Advanced: ---

# When requesting recent versions of a data set, there can be some
# reproducibility issues. For example, requesting data as of the current date
# may return different values based on whether today's data is available yet
# or not. Other factors include the time it takes between data becoming
# available and when you download the data, and whether the data provider
# will overwrite ("clobber") version data rather than just publishing new
# versions. You can include information about these factors by setting the
# `clobberable_versions_start` and `versions_end` of an `epi_archive`, in
# which case you will get warnings about potential reproducibility issues:

archive_cases_dv_subset2 <- as_epi_archive(
  archive_cases_dv_subset$DT,
  # Suppose last version with an update could potentially be rewritten
  # (a.k.a. "hotfixed", "clobbered", etc.):
  clobberable_versions_start = max(archive_cases_dv_subset$DT$version),
  # Suppose today is the following day, and there are no updates out yet:
  versions_end = max(archive_cases_dv_subset$DT$version) + 1L,
  compactify = TRUE
)

epix_as_of(archive_cases_dv_subset2, max(archive_cases_dv_subset$DT$version))


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