Description Usage Arguments Details Value Author(s) Examples
View source: R/derive_var_lstalvdt.R
Add the last known alive date (LSTALVDT
) to the dataset.
1 2 3 4 5 6 | derive_var_lstalvdt(
dataset,
...,
source_datasets,
subject_keys = vars(STUDYID, USUBJID)
)
|
dataset |
Input dataset The variables specified by |
... |
Source(s) of known alive dates. One or more |
source_datasets |
A named |
subject_keys |
Variables to uniquely identify a subject A list of quosures where the expressions are symbols as returned by
|
The following steps are performed to create the output dataset:
For each source dataset the observations as specified by
the filter
element are selected. Then for each patient the last
observation (with respect to date
) is selected.
The LSTALVDT
variable is set to the variable specified by the
date
element. If the date variable is a datetime variable, only
the datepart is copied. If the source variable is a character variable, it
is converted to a date. If the date is incomplete, it is imputed as
specified by the date_imputation
element.
The variables specified by the traceability_vars
element are
added.
The selected observations of all source datasets are combined into a single dataset.
For each patient the last observation (with respect to the LSTALVDT
variable) from the single dataset is selected and the new variable is
merged to the input dataset.
The input dataset with the LSTALVDT
variable added.
Stefan Bundfuss, Thomas Neitmann
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data("dm")
data("ae")
data("lb")
data("adsl")
ae_start <- lstalvdt_source(
dataset_name = "ae",
date = AESTDTC,
date_imputation = "first"
)
ae_end <- lstalvdt_source(
dataset_name = "ae",
date = AEENDTC,
date_imputation = "first"
)
lb_date <- lstalvdt_source(
dataset_name = "lb",
date = LBDTC,
filter = nchar(LBDTC) >= 10
)
adsl_date <- lstalvdt_source(dataset_name = "adsl", date = TRTEDT)
dm %>%
derive_var_lstalvdt(
ae_start, ae_end, lb_date, adsl_date,
source_datasets = list(adsl = adsl, ae = ae, lb = lb)
) %>%
select(USUBJID, LSTALVDT)
# derive last alive date and traceability variables
ae_start <- lstalvdt_source(
dataset_name = "ae",
date = AESTDTC,
date_imputation = "first",
traceability_vars = vars(
LALVDOM = "AE",
LALVSEQ = AESEQ,
LALVVAR = "AESTDTC"
)
)
ae_end <- lstalvdt_source(
dataset_name = "ae",
date = AEENDTC,
date_imputation = "first",
traceability_vars = vars(
LALVDOM = "AE",
LALVSEQ = AESEQ,
LALVVAR = "AEENDTC"
)
)
lb_date <- lstalvdt_source(
dataset_name = "lb",
date = LBDTC,
filter = nchar(LBDTC) >= 10,
traceability_vars = vars(
LALVDOM = "LB",
LALVSEQ = LBSEQ,
LALVVAR = "LBDTC"
)
)
adsl_date <- lstalvdt_source(
dataset_name = "adsl",
date = TRTEDT,
traceability_vars = vars(
LALVDOM = "ADSL",
LALVSEQ = NA_integer_,
LALVVAR = "TRTEDTM"
)
)
dm %>%
derive_var_lstalvdt(
ae_start, ae_end, lb_date, adsl_date,
source_datasets = list(adsl = adsl, ae = ae, lb = lb)
) %>%
select(USUBJID, LSTALVDT, LALVDOM, LALVSEQ, LALVVAR)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.