
Adds a Parameter Indicating If a Subject Had a Response before Progressive Disease
Source:R/derive_param_response.R
derive_param_response.RdAdds a parameter indicating if a response has been observed.
If a response has been observed, AVALC is set to "Y", AVAL to 1 and ADT
is set to the
first date when a response has been observed.
If a response has not been observed, AVALC is set to "N", AVAL to 0 and
ADT is set NA.
Usage
derive_param_response(
dataset,
dataset_adsl,
filter_source,
source_pd = NULL,
source_datasets = NULL,
set_values_to,
aval_fun = yn_to_numeric,
subject_keys = get_admiral_option("subject_keys")
)Arguments
- dataset
Input dataset
The variables specified by the
subject_keysandADTare expected.After applying
filter_sourceand/orsource_pdthe variableADTand the variables specified bysubject_keysmust be a unique key of the dataset.- dataset_adsl
Input dataset
The variables specified for
subject_keysare expected.For each observation of the specified dataset a new observation is added to the input dataset. This is to capture those patients that may never have had a tumor assessment.
- filter_source
Source filter
All observations in the
datasetdata fulfilling the specified condition are selected.- source_pd
Sources and conditions defining the end of the assessment period for the responses.
An object of type
date_sourceis expectedAll observations in
datasetdefining the response data fulfilling thefilter_sourcecondition are considered as response if they fall before the end of the assessment period as defined bysource_pd.For subjects with at least one response before the end of the assessment period,
AVALCis set to"Y",AVALto1, andADTto the first date when the response occurred.For all other subjects
AVALCis set to"N",AVALto0, andADTtoNA.
- source_datasets
Source dataset
A named list of datasets with one element is expected (e.g.
list(adrs= adrs)).The name must match the
dataset_namefield of theadmiral::date_source()object specified forsource_pd.The variables specified by the
subject_keysargument and thedatefield of theadmiral::date_source()object are expected in the dataset.- set_values_to
Variables to set
A named list returned by
vars()defining the variables to be set for the new parameter, e.g.vars(PARAMCD = "RSP", PARAM = "Response by investigator")is expected.The values must be symbols, character strings, numeric values or
NA.- aval_fun
Function to map character analysis value (
AVALC) to numeric analysis value (AVAL)The (first) argument of the function must expect a character vector and the function must return a numeric vector.
- subject_keys
Variables to uniquely identify a subject
A list of symbols created using
vars()is expected.
Details
The Date of the end of the assessment period (e.g. Progressive disease, as defined by
pd_source) is added to the response dataset.The response dataset is restricted to observations occurring before ** or on ** the date of progressive disease.
For each subject (with respect to the variables specified for the
subject_keysparameter), the first observation (with respect toADT) where the response condition (filter_sourceparameter) is fulfilled is selected.For each observation in
dataset_adsla new observation is created.
For subjects with a response
AVALCis set to"Y",AVALto1, andADTto the first date (ADT) where the response condition is fulfilled.For all other subjects
AVALCis set to"N",AVALto0andADTtoNA.
The variables specified by the
set_values_toparameter are added to the new observations.The new observations are added to input dataset.
See also
ADRS Functions for adding Parameters:
derive_param_bor(),
derive_param_clinbenefit(),
derive_param_confirmed_bor(),
derive_param_confirmed_resp()
Examples
library(dplyr)
library(admiral)
library(lubridate)
library(rlang)
#>
#> Attaching package: ‘rlang’
#> The following object is masked from ‘package:magrittr’:
#>
#> set_names
adsl <- tibble::tribble(
~USUBJID,
"1",
"2",
"3",
"4"
) %>%
mutate(STUDYID = "XX1234")
adrs <- tibble::tribble(
~USUBJID, ~PARAMCD, ~ADTC, ~AVALC, ~ANL01FL,
"1", "OVR", "2020-01-02", "PR", "Y",
"1", "OVR", "2020-02-01", "CR", "Y",
"1", "OVR", "2020-03-01", "CR", "Y",
"1", "OVR", "2020-04-01", "SD", "Y",
"1", "PD", NA_character_, "N", "Y",
"2", "OVR", "2021-06-15", "SD", "Y",
"2", "OVR", "2021-07-16", "PD", "Y",
"2", "OVR", "2021-09-14", "PD", "Y",
"2", "PD", "2021-09-14", "Y", "Y",
"3", "OVR", "2021-09-14", "SD", "Y",
"3", "OVR", "2021-10-30", "PD", "Y",
"3", "OVR", "2021-12-25", "CR", "Y",
"3", "PD", "2021-10-30", "Y", "Y"
) %>%
mutate(
STUDYID = "XX1234",
ADT = ymd(ADTC),
ANL01FL = "Y"
) %>%
select(-ADTC)
# Define the end of the assessment period for responses:
# all responses before or on the first PD will be used.
pd <- date_source(
dataset_name = "adrs",
date = ADT,
filter = PARAMCD == "PD" & AVALC == "Y"
)
# Derive the response parameter
derive_param_response(
dataset = adrs,
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & AVALC %in% c("CR", "PR") & ANL01FL == "Y",
source_pd = pd,
source_datasets = list(adrs = adrs),
set_values_to = vars(
PARAMCD = "RSP",
PARAM = "Response by investigator"
),
subject_keys = get_admiral_option("subject_keys")
) %>%
arrange(USUBJID, PARAMCD, ADT)
#> # A tibble: 17 x 8
#> USUBJID PARAMCD AVALC ANL01FL STUDYID ADT PARAM AVAL
#> <chr> <chr> <chr> <chr> <chr> <date> <chr> <dbl>
#> 1 1 OVR PR Y XX1234 2020-01-02 NA NA
#> 2 1 OVR CR Y XX1234 2020-02-01 NA NA
#> 3 1 OVR CR Y XX1234 2020-03-01 NA NA
#> 4 1 OVR SD Y XX1234 2020-04-01 NA NA
#> 5 1 PD N Y XX1234 NA NA NA
#> 6 1 RSP Y Y XX1234 2020-01-02 Response by investiga… 1
#> 7 2 OVR SD Y XX1234 2021-06-15 NA NA
#> 8 2 OVR PD Y XX1234 2021-07-16 NA NA
#> 9 2 OVR PD Y XX1234 2021-09-14 NA NA
#> 10 2 PD Y Y XX1234 2021-09-14 NA NA
#> 11 2 RSP N NA XX1234 NA Response by investiga… 0
#> 12 3 OVR SD Y XX1234 2021-09-14 NA NA
#> 13 3 OVR PD Y XX1234 2021-10-30 NA NA
#> 14 3 OVR CR Y XX1234 2021-12-25 NA NA
#> 15 3 PD Y Y XX1234 2021-10-30 NA NA
#> 16 3 RSP N NA XX1234 NA Response by investiga… 0
#> 17 4 RSP N NA XX1234 NA Response by investiga… 0