Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/derive_var_last_dose_grp.R
Add a variable for user-defined dose grouping of the last dose to the input dataset.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  | derive_var_last_dose_grp(
  dataset,
  dataset_ex,
  filter_ex = NULL,
  by_vars = vars(STUDYID, USUBJID),
  dose_id = vars(),
  dose_date,
  analysis_date,
  single_dose_condition = (EXDOSFRQ == "ONCE"),
  new_var,
  grp_brks,
  grp_lbls,
  include_lowest = TRUE,
  right = TRUE,
  dose_var = EXDOSE,
  traceability_vars = NULL
)
 | 
dataset | 
 Input dataset.
The variables specified by the   | 
dataset_ex | 
 Input EX dataset.
The variables specified by the   | 
filter_ex | 
 Filtering condition applied to EX dataset. For example, it can be used to filter for valid dose. Defaults to NULL.  | 
by_vars | 
 Variables to join by (created by   | 
dose_id | 
 Variables to identify unique dose (created by   | 
dose_date | 
 The EX dose date variable.  | 
analysis_date | 
 The analysis date variable.  | 
single_dose_condition | 
 The condition for checking if   | 
new_var | 
 The output variable defined by the user.  | 
grp_brks | 
 User supplied breaks to apply to groups.
Refer to   | 
grp_lbls | 
 User supplied labels to apply to groups.
Refer to   | 
include_lowest | 
 logical, indicating if a value equal to the lowest
(or highest, for right = FALSE) ‘breaks’ value should be included.
Refer to   | 
right | 
 Logical, indicating if the intervals should be closed on the right
(and open on the left) or vice versa.
Refer to   | 
dose_var | 
 The source dose amount variable. Defaults to   | 
traceability_vars | 
 A named list returned by   | 
Last dose is the dose with maximum dose_date that is lower to or equal to the
analysis_date per by_vars for each observation in dataset.
The last dose group is then derived by user-defined grouping, which groups
dose_var as specified in grp_brks, and returns grp_lbls as the values for new_var.
Input dataset with additional column new_var.
Ben Straub
derive_vars_last_dose(), cut()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  | library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data(ae)
data(ex_single)
ae %>%
   head(100) %>%
   derive_var_last_dose_grp(
   head(ex_single, 100),
   filter_ex = (EXDOSE > 0 | (EXDOSE == 0 & grepl("PLACEBO", EXTRT))) &
   nchar(EXENDTC) >= 10,
   by_vars = vars(STUDYID, USUBJID),
   dose_date = EXSTDTC,
   new_var = LDGRP,
   grp_brks = c(0, 20, 40, 60),
   grp_lbls = c("Low", "Medium", "High"),
   include_lowest = TRUE,
   right = TRUE,
   dose_var = EXDOSE,
   analysis_date = AESTDTC,
   single_dose_condition = (EXSTDTC == EXENDTC),
   traceability_vars = dplyr::vars(LDOSEDOM = "EX", LDOSESEQ = EXSEQ, LDOSEVAR = "EXENDTC")
   ) %>%
   select(USUBJID, LDGRP, LDOSEDOM, LDOSESEQ, LDOSEVAR)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.