
Calculate percentage of subjects with events by treatment and stratum
Source:R/by_strata_by_trt.R
p_subj_event.RdCalculate the percentage of subjects with events by treatment and stratum.
Arguments
- dat
data.table. The analysis data set.
- event_index
vector of integers that index the rows in
datthat match the definition of an 'event'. Matching is done via theINDEX_column indat.- cell_index
A vector of integers referencing the rows of
dat(as specified by theINDEX_column indat) that match the population to be analyzed. See the "Endpoint Events" vignette in ramnog for more information.- subjectid_var
character. Name of the subject identifier variable in the data (default is "USUBJID").
- ...
Optional parameters.
Value
A data.table containing the percentage of subjects with events for the given combination of treatment and stratum
Examples
dat <- data.table::data.table(USUBJID = c("S1", "S2", "S3", "S4"))
dat[, INDEX_ := .I]
#> USUBJID INDEX_
#> <char> <int>
#> 1: S1 1
#> 2: S2 2
#> 3: S3 3
#> 4: S4 4
data.table::setkey(dat, INDEX_)
p_subj_event(dat, event_index = c(1L, 2L), cell_index = dat[["INDEX_"]],
subjectid_var = "USUBJID")
#> description qualifiers label value
#> <char> <char> <char> <num>
#> 1: Proportion of subjects with events <NA> (%) 50