extend_source_datasets: Add By Groups to All Datasets if Necessary

View source: R/derive_param_tte.R

extend_source_datasetsR 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

See Also

Other Advanced Functions: assert_db_requirements(), assert_terms(), assert_valid_queries(), filter_date_sources(), format.basket_select(), list_tte_source_objects(), params(), validate_basket_select(), validate_query()

Examples

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

adsl <- 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 <- 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 = exprs(AEDECOD)
)

admiral documentation built on Oct. 19, 2023, 1:08 a.m.