derive_last_dose: Derive Last Dose Date(-time)

Description Usage Arguments Details Value Author(s) Examples

View source: R/derive_last_dose.R

Description

[Deprecated]

Deprecated, please use derive_var_last_dose_date() instead.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
derive_last_dose(
  dataset,
  dataset_ex,
  filter_ex = NULL,
  by_vars = vars(STUDYID, USUBJID),
  dose_start,
  dose_end,
  analysis_date,
  dataset_seq_var,
  new_var,
  output_datetime = TRUE,
  check_dates_only = FALSE,
  traceability_vars = NULL
)

Arguments

dataset

Input dataset.

dataset_ex

Input EX dataset.

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 dplyr::vars).

dose_start

The dose start date variable.

dose_end

The dose end date variable.

analysis_date

The analysis date variable.

dataset_seq_var

The sequence variable (this together with by_vars creates the keys of dataset).

new_var

The output variable.

output_datetime

Logical. Should only date or date-time variable be returned? Defaults to TRUE (i.e. date-time variable).

check_dates_only

Logical. An assumption that start and end dates of treatment match is checked. By default (FALSE), the date as well as the time component is checked. If set to TRUE, then only the date component of those variables is checked.

traceability_vars

A named list returned by vars() listing the traceability variables, e.g. vars(LDOSEDOM = "EX", LDOSESEQ = EXSEQ). The left-hand side (names of the list elements) gives the names of the traceability variables in the returned dataset. The right-hand side (values of the list elements) gives the values of the traceability variables in the returned dataset. These can be either strings or symbols referring to existing variables.

Details

All date (date-time) variables can be characters in standard ISO format or of date / date-time class. For ISO format, see impute_dtc - parameter dtc for further details. Date-time imputations are done as follows:

The last dose date is derived as follows:

  1. The dataset_ex is filtered using filter_ex, if provided. This is useful for, for example, filtering for valid dose only.

  2. The datasets dataset and dataset_ex are joined using by_vars.

  3. The last dose date is derived: the last dose date is the maximum date where dose_end is lower to or equal to analysis_date, subject to both date values are non-NA. The last dose date is derived per by_vars and dataset_seq_var.

  4. The last dose date is appended to the dataset and returned to the user.

Furthermore, the following assumption is checked: start and end dates (datetimes) need to match. Use check_dates_only to control whether only dates or whole date-times need to be equal.

Value

Input dataset with additional column new_var.

Author(s)

Ondrej Slama

Examples

 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(ex_single)

ae %>%
  head(100) %>%
  derive_last_dose(
    head(ex_single, 100),
    filter_ex = (EXDOSE > 0 | (EXDOSE == 0 & grepl("PLACEBO", EXTRT))) &
      nchar(EXENDTC) >= 10,
    dose_start = EXSTDTC,
    dose_end = EXENDTC,
    analysis_date = AESTDTC,
    dataset_seq_var = AESEQ,
    new_var = LDOSEDTM,
    output_datetime = TRUE,
    check_dates_only = FALSE
  ) %>%
  select(STUDYID, USUBJID, AESEQ, AESTDTC, LDOSEDTM)

# or with traceability variables
ae %>%
  head(100) %>%
  derive_last_dose(
    head(ex_single, 100),
    filter_ex = (EXDOSE > 0 | (EXDOSE == 0 & grepl("PLACEBO", EXTRT))) &
      nchar(EXENDTC) >= 10,
    dose_start = EXSTDTC,
    dose_end = EXENDTC,
    analysis_date = AESTDTC,
    dataset_seq_var = AESEQ,
    new_var = LDOSEDTM,
    output_datetime = TRUE,
    check_dates_only = FALSE,
    traceability_vars = dplyr::vars(LDOSEDOM = "EX", LDOSESEQ = EXSEQ, LDOSEVAR = "EXSTDTC")
  ) %>%
  select(STUDYID, USUBJID, AESEQ, AESTDTC, LDOSEDTM, LDOSEDOM, LDOSESEQ, LDOSEVAR)

epijim/admiral documentation built on Feb. 13, 2022, 12:15 a.m.