extend_source_datasets {admiral}R Documentation

Add By Groups to All Datasets if Necessary

Description

The function ensures that the by variables are contained in all source datasets.

Usage

extend_source_datasets(source_datasets, by_vars)

Arguments

source_datasets

Source datasets

A named list of datasets is expected. Each dataset must contain either all by variables or none of the by variables.

by_vars

By variables

Details

  1. The by groups are determined as the union of the by groups occurring in the source datasets.

  2. For all source datasets which do not contain the by variables the source dataset is replaced by the cartesian product of the source dataset and the by groups.

Value

The list of extended source datasets

Author(s)

Stefan Bundfuss

See Also

Source Specifications: assert_db_requirements(), assert_terms(), assert_valid_queries(), censor_source(), date_source(), death_event, derive_var_dthcaus(), event_source(), filter_date_sources(), format.sdg_select(), format.smq_select(), list_tte_source_objects(), params(), query(), sdg_select(), smq_select(), tte_source(), validate_query(), validate_sdg_select(), validate_smq_select()

Examples

library(dplyr, warn.conflicts = FALSE)
library(lubridate)

adsl <- tibble::tribble(
  ~USUBJID, ~TRTSDT,           ~EOSDT,
  "01",     ymd("2020-12-06"), ymd("2021-03-06"),
  "02",     ymd("2021-01-16"), ymd("2021-02-03")
) %>%
  mutate(STUDYID = "AB42")

ae <- tibble::tribble(
  ~USUBJID, ~AESTDTC,           ~AESEQ, ~AEDECOD,
  "01",     "2021-01-03T10:56", 1,      "Flu",
  "01",     "2021-03-04",       2,      "Cough",
  "01",     "2021",             3,      "Flu"
) %>%
  mutate(STUDYID = "AB42")

extend_source_datasets(
  source_datasets = list(adsl = adsl, ae = ae),
  by_vars = vars(AEDECOD)
)

[Package admiral version 0.8.4 Index]