Description Usage Arguments Value Author(s) See Also Examples
View source: R/call_derivation.R
Call a single derivation multiple times with some parameters being fixed across iterations and others varying.
1 | call_derivation(dataset = NULL, derivation, variable_params, ...)
|
dataset |
The input dataset |
derivation |
The derivation function to call |
variable_params |
A |
... |
Any number of named arguments that are fixed across iterations.
If a parameter is specified both inside |
The input dataset with additional records/variables added depending on
which derivation
has been used.
Thomas Neitmann, Stefan Bundfuss
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 | library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data(ae)
data(adsl)
adae <- ae[sample(1:nrow(ae), 1000), ] %>%
left_join(adsl, by = "USUBJID") %>%
select(USUBJID, AESTDTC, AEENDTC, TRTSDT, TRTEDT)
## While `derive_vars_dt()` can only add one variable at a time, using `call_derivation()`
## one can add multiple variables in one go
call_derivation(
dataset = adae,
derivation = derive_vars_dt,
variable_params = list(
params(dtc = AESTDTC, date_imputation = "first", new_vars_prefix = "AST"),
params(dtc = AEENDTC, date_imputation = "last", new_vars_prefix = "AEN")
),
min_dates = vars(TRTSDT),
max_dates = vars(TRTEDT)
)
## The above call using `call_derivation()` is equivalent to the following
adae %>%
derive_vars_dt(
new_vars_prefix = "AST",
dtc = AESTDTC,
date_imputation = "first",
min_dates = vars(TRTSDT),
max_dates = vars(TRTEDT)
) %>%
derive_vars_dt(
new_vars_prefix = "AEN",
dtc = AEENDTC,
date_imputation = "last",
min_dates = vars(TRTSDT),
max_dates = vars(TRTEDT)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.