survReport: Survival Report

View source: R/todo/survReport.R View source: R/survReport.r

survReportR Documentation

Survival Report

Description

Generate a Survival Report with Kaplan-Meier Estimates

Usage

survReport(
  formula,
  data = NULL,
  subset = NULL,
  na.action = na.retain,
  ylab = NULL,
  what = c("S", "1-S"),
  conf = c("diffbands", "bands", "bars", "none"),
  cause = NULL,
  panel = "surv",
  subpanel = NULL,
  head = NULL,
  tail = NULL,
  h = 3,
  w = 4.5,
  multi = FALSE,
  markevent = TRUE,
  mfrow = NULL,
  y.n.risk = 0,
  mylim = NULL,
  bot = 2,
  aehaz = TRUE,
  times = NULL,
  append = FALSE,
  opts = NULL,
  ...
)

Arguments

formula

a formula with survival (Surv) objects on the left hand side and an optional stratification factor on the right (or 1 if none). The survival object component variables should be labeled; these labels are used for graph annotation. If any of the Surv objects are competing risk objects (see Surv), event labels come from the factor levels in the variable that was the second argument to Surv, and the first factor level must correspond to right-censored observations.

data

data.frame

subset

optional subsetting criteria

na.action

function for handling NAs while creating a data frame

ylab

character. Passed to survplot.npsurv as the ylab argument. Constructed by default.

what

"S" (the default) to plot survival functions or "1-S" to plot cumulative incidence functions. If any of the survival time objects on the left hand side are competing risk objects, the default is "1-S" and you may not change it.

conf

character. See survplot.npsurv.

cause

character vector or list. If a vector, every Surv term on the left hand side of formula will have cumulative incidence plotted for all causes that appear in cause. If a list, the list elements must correspond to the Surv terms in order, and specify which causes to display from the corresponding Surv object. When cause is a list and one of its elements contains more than one character string, or when cause is a vector and for one Surv object it matches multiple causes, survReport produces more plots than there are Surv objects.

panel

character string. Name of panel, which goes into file base names and figure labels for cross-referencing.

subpanel

character string. If calling dReport more than once for the same type of chart (categorical or continuous), specify subpanel to distinguish the multiple calls. In that case, -subpanel will be appended to panel when creating figure labels and cross-references.

head

character string. Specifies initial text in the figure caption, otherwise a default is used.

tail

optional character string. Specifies final text in the figure caption, e.g., what might have been put in a footnote in an ordinary text page. This appears just before any needles.

h

numeric. Height of plots.

w

numeric. Width of plots in inches.

multi

logical. If TRUE, multiple figures are produced, otherwise a single figure with a matrix of survival plots is made.

markevent

logical. Applies only if multi=TRUE. Specify FALSE to not put the event label in the extreme upper left of the plot.

mfrow

numeric 2-vector, used if multi=FALSE. If not specified, default plot matrix layout will be figured.

y.n.risk

used if what="1-S", to specify y coordinate for putting numbers at risk, typically below the x-axis label

mylim

numeric 2-vector. Used to force expansion of computed y-axis limits. See survplot.

bot

number of spaces to reserve at bottom of plot for numbers at risk, if what="1-S"

aehaz

logical. Set to FALSE to not print number of events and hazard rate on plots.

times

numeric vector. If specified, prints cumulative incidence probabilities at those times on the plots.

append

logical. If TRUE output will be appended instead of overwritten.

opts

list. A list specifying arguments to survReport and startPlot that override any other arguments. This is useful when making a long series of survReport calls with the same options, as the options can be defined up front in a list.

...

ignored

Examples

## See tests directory test.Rnw for a live example
## Not run: 
  set.seed(1)
  n <- 400
  dat <- data.frame(t1=runif(n, 2, 5), t2=runif(n, 2, 5),
                    e1=rbinom(n, 1, .5), e2=rbinom(n, 1, .5),
                    treat=sample(c('a','b'), n, TRUE))
  dat <- upData(dat,
                labels=c(t1='Time to operation',
                         t2='Time to rehospitalization',
                         e1='Operation', e2='Hospitalization',
                         treat='Treatment')
                units=c(t1='year', t2='year'))
  survReport(Surv(t1, e1) + Surv(t2, e2) ~ treat, data=dat)

  dat <- upData(dat, labels=c(t1='Follow-up Time', t2='Time'),
                cause=factor(sample(c('death','MI','censor'), n, TRUE),
                             c('censor', 'MI', 'death')))
  survReport(Surv(t1, cause) ~ treat, cause='death', data=dat)
  survReport(Surv(t1, cause) + Surv(t2, cause) ~ treat,
             cause=list(c('death', 'MI'), 'death'), data=dat)
  # Two plots for t1, one plot for t2

## End(Not run)

greport documentation built on Sept. 3, 2023, 1:06 a.m.