Skip to content

Commit 054895d

Browse files
authored
Merge pull request #134 from cmu-delphi/98-improve-documentation-experience-for-users-constructing-first-epi_archive
Improved documentation experience for users constructing first `epi_archive`
2 parents 2fb47ec + 1cb710f commit 054895d

File tree

8 files changed

+111
-61
lines changed

8 files changed

+111
-61
lines changed

.DS_Store

8 KB
Binary file not shown.

R/archive.R

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
#' The data table `DT` has key variables `geo_value`, `time_value`, `version`,
2929
#' as well as any others (these can be specified when instantiating the
3030
#' `epi_archive` object via the `other_keys` argument, and/or set by operating
31-
#' on `DT` directly). There can only be a single row per unique combination of
31+
#' on `DT` directly). Refer to the documentation for [as_epi_archive()] for
32+
#' information and examples of relevant parameter names for an `epi_archive` object.
33+
#' Note that there can only be a single row per unique combination of
3234
#' key variables, and thus the key variables are critical for figuring out how
3335
#' to generate a snapshot of data from the archive, as of a given version.
34-
#'
36+
#'
3537
#' In general, last observation carried forward (LOCF) is used to data in
3638
#' between recorded versions. Currently, deletions must be represented as
3739
#' revising a row to a special state (e.g., making the entries `NA` or
@@ -78,6 +80,19 @@
7880
#'
7981
#' @importFrom R6 R6Class
8082
#' @export
83+
#' @examples
84+
#' tib <- tibble::tibble(
85+
#' geo_value = rep(c("ca", "hi"), each = 5),
86+
#' time_value = rep(seq(as.Date("2020-01-01"),
87+
#' by = 1, length.out = 5), times = 2),
88+
#' version = rep(seq(as.Date("2020-01-02"),
89+
#' by = 1, length.out = 5), times = 2),
90+
#' value = rnorm(10, mean = 2, sd = 1)
91+
#' )
92+
#'
93+
#' toy_epi_archive <- tib %>% epi_archive$new(geo_type = "state",
94+
#' time_type = "day")
95+
#' toy_epi_archive
8196
epi_archive =
8297
R6::R6Class(
8398
classname = "epi_archive",
@@ -104,6 +119,10 @@ epi_archive =
104119
#' fields; named entries from the passed list or will be included as well.
105120
#' @return An `epi_archive` object.
106121
#' @importFrom data.table as.data.table key setkeyv
122+
#'
123+
#' @details
124+
#' Refer to the documentation for [as_epi_archive()] for more information
125+
#' and examples of parameter names.
107126
initialize = function(x, geo_type, time_type, other_keys,
108127
additional_metadata) {
109128
# Check that we have a data frame
@@ -452,6 +471,21 @@ epi_archive =
452471
#'
453472
#' @export
454473
#' @examples
474+
#' # Simple ex. with necessary keys
475+
#' tib <- tibble::tibble(
476+
#' geo_value = rep(c("ca", "hi"), each = 5),
477+
#' time_value = rep(seq(as.Date("2020-01-01"),
478+
#' by = 1, length.out = 5), times = 2),
479+
#' version = rep(seq(as.Date("2020-01-02"),
480+
#' by = 1, length.out = 5), times = 2),
481+
#' value = rnorm(10, mean = 2, sd = 1)
482+
#' )
483+
#'
484+
#' toy_epi_archive <- tib %>% as_epi_archive(geo_type = "state",
485+
#' time_type = "day")
486+
#' toy_epi_archive
487+
#'
488+
#' # Ex. with an additional key for county
455489
#' df <- data.frame (geo_value = c(replicate(2, "ca"), replicate(2, "fl")),
456490
#' county = c(1, 3, 2, 5),
457491
#' time_value = c("2020-06-01",

man/as_epi_archive.Rd

Lines changed: 19 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epi_archive.Rd

Lines changed: 40 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epi_slide.Rd

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epix_as_of.Rd

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epix_merge.Rd

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/epix_slide.Rd

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)