rm_cifsum.RdDisplays event counts and event rates at specified time points for the entire cohort and by group. Gray's test of differences in cumulative incidence is displayed.
rm_cifsum(
data,
time,
status,
group = NULL,
eventcode = 1,
cencode = 0,
eventtimes,
eventtimeunit,
eventtimeLbls = NULL,
CIwidth = 0.95,
unformattedp = FALSE,
na.action = "na.omit",
showCounts = TRUE,
showGraystest = TRUE,
digits = 2,
caption = NULL,
tableOnly = FALSE
)data frame containing survival data
string indicating survival time variable
string indicating event status variable; must have at least 3 levels, e.g. 0 = censor, 1 = event, 2 = competing risk
string or character vector indicating the variable to group observations by
numerical variable indicating event, default is 1
numerical variable indicating censored observation, default is 0
numeric vector specifying when event probabilities should be calculated
unit of time to suffix to the time column label if event probabilities are requested, should be plural
if supplied, a vector the same length as eventtimes with descriptions (useful for displaying years with data provided in months)
width of the event probabilities, default is 95%
boolean indicating if you would like the p-value to be returned unformatted (ie not rounded or prefixed with '<'). Should be used in conjunction with the digits argument.
default is to omit missing values, but can be set to throw and error using na.action='na.fail'
boolean indicating if the at risk, events and censored columns should be output, default is TRUE
boolean indicating Gray's test should be included in the final table, default is TRUE
the number of digits to report in the event probabilities, default is 2.
table caption for markdown output
should a dataframe or a formatted object be returned
A character vector of the event table source code, unless tableOnly=TRUE in which case a data frame is returned
library(survival)
data(pbc)
# Event probabilities at various time points with replacement time labels
rm_cifsum(data=pbc,time='time',status='status',
eventtimes=c(1825,3650),eventtimeLbls=c(5,10),eventtimeunit='yr')
#> <table class="table table" style="margin-left: auto; margin-right: auto; margin-left: auto; margin-right: auto;">
#> <thead>
#> <tr>
#> <th style="text-align:left;position: sticky; top:0; background-color: #FFFFFF;"> Event/Total </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> 5yr (95% CI) </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> 10yr (95% CI) </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:left;"> 25/418 </td>
#> <td style="text-align:right;"> 0.04 (0.03, 0.07) </td>
#> <td style="text-align:right;"> 0.08 (0.05, 0.12) </td>
#> </tr>
#> </tbody>
#> </table>
# Event probabilities by one group
rm_cifsum(data=pbc,time='time',status='status',group='trt',
eventtimes=c(1825,3650),eventtimeunit='day')
#> 106 observations with missing data were removed.
#> <table class="table table" style="margin-left: auto; margin-right: auto; margin-left: auto; margin-right: auto;">
#> <thead>
#> <tr>
#> <th style="text-align:left;position: sticky; top:0; background-color: #FFFFFF;"> Strata </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> Event/Total </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> 1825day (95% CI) </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> 3650day (95% CI) </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:left;"> 1 </td>
#> <td style="text-align:right;"> 10/158 </td>
#> <td style="text-align:right;"> 0.05 (0.02, 0.09) </td>
#> <td style="text-align:right;"> 0.08 (0.04, 0.13) </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> 2 </td>
#> <td style="text-align:right;"> 9/154 </td>
#> <td style="text-align:right;"> 0.04 (0.02, 0.08) </td>
#> <td style="text-align:right;"> 0.08 (0.04, 0.15) </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> </td>
#> <td style="text-align:right;"> Gray's Test </td>
#> <td style="text-align:right;"> ChiSq </td>
#> <td style="text-align:right;"> 0.0 on 1 df </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> </td>
#> <td style="text-align:right;"> </td>
#> <td style="text-align:right;"> p-value </td>
#> <td style="text-align:right;"> 0.89 </td>
#> </tr>
#> </tbody>
#> </table>
# Event probabilities by multiple groups
rm_cifsum(data=pbc,time='time',status='status',group=c('trt','sex'),
eventtimes=c(1825,3650),eventtimeunit='day')
#> 106 observations with missing data were removed.
#> <table class="table table" style="margin-left: auto; margin-right: auto; margin-left: auto; margin-right: auto;">
#> <thead>
#> <tr>
#> <th style="text-align:left;position: sticky; top:0; background-color: #FFFFFF;"> Strata </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> Event/Total </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> 1825day (95% CI) </th>
#> <th style="text-align:right;position: sticky; top:0; background-color: #FFFFFF;"> 3650day (95% CI) </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:left;"> 1, f </td>
#> <td style="text-align:right;"> 7/137 </td>
#> <td style="text-align:right;"> 0.04 (0.01, 0.08) </td>
#> <td style="text-align:right;"> 0.06 (0.03, 0.12) </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> 1, m </td>
#> <td style="text-align:right;"> 3/21 </td>
#> <td style="text-align:right;"> 0.10 (0.02, 0.27) </td>
#> <td style="text-align:right;"> 0.16 (0.03, 0.36) </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> 2, f </td>
#> <td style="text-align:right;"> 9/139 </td>
#> <td style="text-align:right;"> 0.05 (0.02, 0.09) </td>
#> <td style="text-align:right;"> 0.09 (0.04, 0.17) </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> 2, m </td>
#> <td style="text-align:right;"> 0/15 </td>
#> <td style="text-align:right;"> 0e+00 (NA, NA) </td>
#> <td style="text-align:right;"> 0e+00 (NA, NA) </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> </td>
#> <td style="text-align:right;"> Gray's Test </td>
#> <td style="text-align:right;"> ChiSq </td>
#> <td style="text-align:right;"> 3.3 on 3 df </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;"> </td>
#> <td style="text-align:right;"> </td>
#> <td style="text-align:right;"> p-value </td>
#> <td style="text-align:right;"> 0.35 </td>
#> </tr>
#> </tbody>
#> </table>