Skip to contents

Add new variables to the input dataset based on variables from another dataset. The variables to be added to the output dataset will be based on input variables passed on ex_vars argument.

Usage

derive_vars_merged_vaccine(
  dataset,
  dataset_ex,
  by_vars_sys,
  by_vars_adms,
  dataset_supp = NULL,
  dataset_suppex = NULL,
  ex_vars
)

Arguments

dataset

Input dataset

The variables specified by the by_vars argument inside the derive_vars_mergedare expected.

dataset_ex

EX dataset to merge with the input dataset.

The variables specified by the ex_vars argument are expected.

by_vars_sys

Grouping variables for systemic events.

by_vars_adms

Grouping variables for administration site events.

dataset_supp

Supplementary input dataset

By default dataset_supp will be NULL, user has to provide supplementary dataset to merge it back with original input dataset if they have supplementary dataset in their case.

dataset_suppex

Supplementary EX dataset

By default dataset_suppex will be NULL, user has to provide supplementary dataset to merge it back with original EX dataset if they have supplementary dataset in their case.

ex_vars

Variables to be added to the output dataset from EX dataset

Value

The dataset with variables added from the EX dataset.

Details

The input dataset will be merged with EX dataset for "ADMINISTRATION SITE" and "SYSTEMIC" categories separately and these datasets will be bound together as the final output dataset.

This function is intended to add only EX variables to the input dataset and user is expected to handle if any pre-processing is required.

Only the variables passed to the ex_vars will be added in the output dataset

If the input dataset has multiple vaccination for a subject at same visit then this function will not merge ex dataset and will return only the input dataset merged with its supplementary dataset.

Author

Vikram S

Examples


library(tibble)
library(admiral)
library(dplyr)
library(pharmaversesdtm)

derive_vars_merged_vaccine(
  dataset = face_vaccine,
  dataset_ex = ex_vaccine,
  dataset_supp = NULL,
  dataset_suppex = NULL,
  by_vars_sys = exprs(USUBJID, FATPTREF = EXLNKGRP),
  by_vars_adms = exprs(USUBJID, FATPTREF = EXLNKGRP, FALOC = EXLOC, FALAT = EXLAT),
  ex_vars = exprs(EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC)
) %>%
  select(USUBJID, FATPTREF, FALOC, FALAT, EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC) %>%
  head(10)
#> # A tibble: 10 × 9
#>    USUBJID  FATPTREF      FALOC        FALAT EXTRT EXDOSE EXDOSU EXSTDTC EXENDTC
#>    <chr>    <chr>         <chr>        <chr> <chr>  <dbl> <chr>  <chr>   <chr>  
#>  1 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  2 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  3 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  4 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  5 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  6 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  7 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  8 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#>  9 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…
#> 10 ABC-1001 VACCINATION 1 DELTOID MUS… LEFT  VACC…      1 SYRIN… 2021-1… 2021-1…

derive_vars_merged_vaccine(
  dataset = face_vaccine,
  dataset_ex = ex_vaccine,
  dataset_supp = suppface_vaccine,
  dataset_suppex = suppex_vaccine,
  by_vars_sys = exprs(USUBJID, FATPTREF = EXLNKGRP),
  by_vars_adms = exprs(USUBJID, FATPTREF = EXLNKGRP, FALOC = EXLOC, FALAT = EXLAT),
  ex_vars = exprs(EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC)
) %>%
  filter(CLTYP == "DAIRY") %>%
  select(USUBJID, FATPTREF, CLTYP, EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC)
#> # A tibble: 4 × 8
#>   USUBJID  FATPTREF      CLTYP EXTRT     EXDOSE EXDOSU  EXSTDTC          EXENDTC
#>   <chr>    <chr>         <chr> <chr>      <dbl> <chr>   <chr>            <chr>  
#> 1 ABC-1001 VACCINATION 1 DAIRY VACCINE A      1 SYRINGE 2021-11-03T10:5… 2021-1…
#> 2 ABC-1001 VACCINATION 1 DAIRY VACCINE A      1 SYRINGE 2021-11-03T10:5… 2021-1…
#> 3 ABC-1002 VACCINATION 1 DAIRY VACCINE A      1 SYRINGE 2021-10-07T12:4… 2021-1…
#> 4 ABC-1002 VACCINATION 1 DAIRY VACCINE A      1 SYRINGE 2021-10-07T12:4… 2021-1…