rm_survdiff {reportRmd} | R Documentation |
Display event counts, expected event counts and logrank test of differences
Description
This is a wrapper function around the survdiff function to display overall event rates and group-specific rates along with the log-rank test of a difference in survival between groups in a single table suitable for markdown output. Median survival times are included by default but can be removed setting median=FALSE
Usage
rm_survdiff(
data,
time,
status,
covs,
strata,
includeVarNames = FALSE,
digits = 1,
showCols = c("N", "Observed", "Expected"),
CIwidth = 0.95,
conf.type = "log",
caption = NULL,
tableOnly = FALSE,
fontsize
)
Arguments
data |
data frame containing survival data |
time |
string indicating survival time variable |
status |
string indicating event status variable |
covs |
character vector indicating variables to group observations by |
strata |
string indicating the variable to stratify observations by |
includeVarNames |
boolean indicating if the variable names should be included in the output table, default is FALSE |
digits |
the number of digits in the survival rate |
showCols |
character vector indicating which of the optional columns to display, defaults to c('N','Observed','Expected') |
CIwidth |
width of the median survival estimates, default is 95% |
conf.type |
type of confidence interval see |
caption |
table caption |
tableOnly |
should a dataframe or a formatted object be returned |
fontsize |
PDF/HTML output only, manually set the table fontsize |
Value
A character vector of the survival table source code, unless tableOnly=TRUE in which case a data frame is returned
See Also
Examples
#' # Differences between sex
data("pembrolizumab")
rm_survdiff(data=pembrolizumab,time='os_time',status='os_status',
covs='sex',digits=1)
# Differences between sex, stratified by cohort
rm_survdiff(data=pembrolizumab,time='os_time',status='os_status',
covs='sex',strata='cohort',digits=1)
# Differences between sex/cohort groups
rm_survdiff(data=pembrolizumab,time='os_time',status='os_status',
covs=c('sex','cohort'),digits=1)