derive_var_disposition_dt: Derive a Disposition Date

Description Usage Arguments Value Author(s) Examples

View source: R/derive_var_disposition_dt.R

Description

[Questioning]

Derive a disposition status date from the the relevant records in the disposition domain.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
derive_var_disposition_dt(
  dataset,
  dataset_ds,
  new_var,
  dtc,
  filter_ds,
  date_imputation = NULL,
  preserve = FALSE,
  subject_keys = vars(STUDYID, USUBJID)
)

Arguments

dataset

Input dataset

dataset_ds

Datasets containing the disposition information (e.g.: ds)

It must contain:

  • STUDYID, USUBJID,

  • The variable(s) specified in the dtc

  • The variables used in filter_ds.

new_var

Name of the disposition date variable

a variable name is expected

dtc

The character date used to derive/impute the disposition date

A character date is expected in a format like yyyy-mm-dd or yyyy-mm-ddThh:mm:ss. If the year part is not recorded (missing date), no imputation is performed.

filter_ds

Filter condition for the disposition data.

Filter used to select the relevant disposition data. It is expected that the filter restricts dataset_ds such that there is at most one observation per patient. An error is issued otherwise.

Permitted Values: logical expression.

date_imputation

The value to impute the day/month when a datepart is missing.

If NULL: no date imputation is performed and partial dates are returned as missing.

Otherwise, a character value is expected, either as a

  • format with day and month specified as 'mm-dd': e.g. '06-15' for the 15th of June

  • or as a keyword: 'FIRST', 'MID', 'LAST' to impute to the first/mid/last day/month.

Default is NULL

preserve

Preserve day if month is missing and day is present

For example "2019---07" would return "2019-06-07 if preserve = TRUE (and date_imputation = "MID").

Permitted Values: TRUE, FALSE

Default: FALSE

subject_keys

Variables to uniquely identify a subject

A list of quosures where the expressions are symbols as returned by vars() is expected.

Value

the input dataset with the disposition date (new_var) added

Author(s)

Samia Kabi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data("dm")
data("ds")

dm %>%
  derive_var_disposition_dt(
    dataset_ds = ds,
    new_var = FRVDT,
    dtc = DSSTDTC,
    filter_ds = DSCAT == "OTHER EVENT" & DSDECOD == "FINAL RETRIEVAL VISIT"
  ) %>%
  select(STUDYID, USUBJID, FRVDT)

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