Derives dataset of single dose from aggregate dose information. This may be
necessary when e.g. calculating last dose before an adverse event in ADAE
or deriving a total dose parameter in ADEX
when EXDOSFRQ != ONCE
.
Usage
create_single_dose_dataset(
dataset,
dose_freq = EXDOSFRQ,
start_date = ASTDT,
start_datetime = NULL,
end_date = AENDT,
end_datetime = NULL,
lookup_table = dose_freq_lookup,
lookup_column = CDISC_VALUE,
keep_source_vars = quo_c(vars(USUBJID), dose_freq, start_date, start_datetime,
end_date, end_datetime)
)
Arguments
- dataset
Input dataset
The columns specified by
dose_freq
,start_date
and theend_date
parameters are expected.- dose_freq
The dose frequency
The aggregate dosing frequency used for multiple doses in a row.
Permitted Values: defined by lookup table.
- start_date
The start date
A date object is expected. This object cannot contain
NA
values.Refer to
derive_vars_dt()
to impute and derive a date from a date character vector to a date object.- start_datetime
The start date-time
A date-time object is expected. This object cannot contain
NA
values.Refer to
derive_vars_dtm()
to impute and derive a date-time from a date character vector to a date object.If the input dataset contains frequencies which refer to
DOSE_WINDOW
equals"HOUR"
or"MINUTE"
, the parameter must be specified.- end_date
The end date
A date or date-time object is expected. This object cannot contain
NA
values.Refer to
derive_vars_dt()
to impute and derive a date from a date character vector to a date object.- end_datetime
The end date-time
A date-time object is expected. This object cannot contain
NA
values.Refer to
derive_vars_dtm()
to impute and derive a date-time from a date character vector to a date object.If the input dataset contains frequencies which refer to
DOSE_WINDOW
equals"HOUR"
or"MINUTE"
, the parameter must be specified.- lookup_table
The dose frequency value lookup table
The table used to look up
dose_freq
values and determine the appropriate multiplier to be used for row generation. If a lookup table other than the default is used, it must have columnsDOSE_WINDOW
,DOSE_COUNT
, andCONVERSION_FACTOR
. The default tabledose_freq_lookup
is described in detail here.Permitted Values for
DOSE_WINDOW
:"MINUTE"
,"HOUR"
,"DAY"
,"WEEK"
,"MONTH"
,"YEAR"
- lookup_column
The dose frequency value column in the lookup table
The column of
lookup_table
.- keep_source_vars
List of variables to be retained from source dataset
This parameter can be specified if additional information is required in the output dataset. For example
EXTRT
for studies with more than one drug.
Details
Each aggregate dose row is split into multiple rows which each
represent a single dose.The number of completed dose periods between
start_date
or start_datetime
and end_date
or end_datetime
is
calculated with compute_duration
and multiplied by DOSE_COUNT
.
For DOSE_WINDOW
values of "WEEK"
, "MONTH"
, and "YEAR"
,
CONVERSION_FACTOR
is used to convert into days the time object
to be added to start_date
.
Observations with dose frequency "ONCE"
are copied to the output dataset
unchanged.
See also
Creating auxiliary datasets:
create_period_dataset()
,
create_query_data()
Examples
# Example with default lookup
library(lubridate)
library(stringr)
library(tibble)
data <- tribble(
~USUBJID, ~EXDOSFRQ, ~ASTDT, ~ASTDTM, ~AENDT, ~AENDTM,
"P01", "Q2D", ymd("2021-01-01"), ymd_hms("2021-01-01 10:30:00"),
ymd("2021-01-07"), ymd_hms("2021-01-07 11:30:00"),
"P01", "Q3D", ymd("2021-01-08"), ymd_hms("2021-01-08 12:00:00"),
ymd("2021-01-14"), ymd_hms("2021-01-14 14:00:00"),
"P01", "EVERY 2 WEEKS", ymd("2021-01-15"), ymd_hms("2021-01-15 09:57:00"),
ymd("2021-01-29"), ymd_hms("2021-01-29 10:57:00")
)
create_single_dose_dataset(data)
#> # A tibble: 9 x 4
#> USUBJID EXDOSFRQ ASTDT AENDT
#> <chr> <chr> <date> <date>
#> 1 P01 ONCE 2021-01-01 2021-01-01
#> 2 P01 ONCE 2021-01-03 2021-01-03
#> 3 P01 ONCE 2021-01-05 2021-01-05
#> 4 P01 ONCE 2021-01-07 2021-01-07
#> 5 P01 ONCE 2021-01-08 2021-01-08
#> 6 P01 ONCE 2021-01-11 2021-01-11
#> 7 P01 ONCE 2021-01-14 2021-01-14
#> 8 P01 ONCE 2021-01-15 2021-01-15
#> 9 P01 ONCE 2021-01-29 2021-01-29
# Example with custom lookup
custom_lookup <- tribble(
~Value, ~DOSE_COUNT, ~DOSE_WINDOW, ~CONVERSION_FACTOR,
"Q30MIN", (1 / 30), "MINUTE", 1,
"Q90MIN", (1 / 90), "MINUTE", 1
)
data <- tribble(
~USUBJID, ~EXDOSFRQ, ~ASTDT, ~ASTDTM, ~AENDT, ~AENDTM,
"P01", "Q30MIN", ymd("2021-01-01"), ymd_hms("2021-01-01T06:00:00"),
ymd("2021-01-01"), ymd_hms("2021-01-01T07:00:00"),
"P02", "Q90MIN", ymd("2021-01-01"), ymd_hms("2021-01-01T06:00:00"),
ymd("2021-01-01"), ymd_hms("2021-01-01T09:00:00")
)
create_single_dose_dataset(data,
lookup_table = custom_lookup,
lookup_column = Value,
start_datetime = ASTDTM,
end_datetime = AENDTM
)
#> # A tibble: 6 x 6
#> USUBJID EXDOSFRQ ASTDT ASTDTM AENDT AENDTM
#> <chr> <chr> <date> <dttm> <date> <dttm>
#> 1 P01 ONCE 2021-01-01 2021-01-01 06:00:00 2021-01-01 2021-01-01 06:00:00
#> 2 P01 ONCE 2021-01-01 2021-01-01 06:30:00 2021-01-01 2021-01-01 06:30:00
#> 3 P01 ONCE 2021-01-01 2021-01-01 07:00:00 2021-01-01 2021-01-01 07:00:00
#> 4 P02 ONCE 2021-01-01 2021-01-01 06:00:00 2021-01-01 2021-01-01 06:00:00
#> 5 P02 ONCE 2021-01-01 2021-01-01 07:30:00 2021-01-01 2021-01-01 07:30:00
#> 6 P02 ONCE 2021-01-01 2021-01-01 09:00:00 2021-01-01 2021-01-01 09:00:00