ciplot_by: ciplot_by

View source: R/plot.R

ciplot_byR Documentation

ciplot_by

Description

This function helps create stratified ciplots quickly with panel labels and Gray's tests for each plot.

Usage

ciplot_by(
  rhs = "1",
  event,
  data,
  by = NULL,
  single = TRUE,
  cencode = NULL,
  gy_test = TRUE,
  main = NULL,
  ylab = NULL,
  sub = NULL,
  groups_lab = NULL,
  fig_lab = NULL,
  col.ci = NULL,
  map.col = FALSE,
  time = NULL,
  add = FALSE,
  plot = TRUE,
  ...
)

Arguments

rhs

the right-hand side of the formula

event

character string indicating the event; see details

data

data frame to use

by

optional character string of stratification variable

single

logical; if TRUE, each level of by will be drawn in a separate window

cencode

unique value of event denoting censoring

gy_test

one of FALSE (no test performed), a numeric value (passed to cuminc as the rho value), or TRUE (default, rho = 0)

main

title(s) of plot(s)

ylab

y-axis label

sub

sub-title displayed in upper left corner; should be a character vector with length equal to the number of panels (i.e., the number of unique values of by or length one if by was not given)

groups_lab

events table group labels; should be a character vector with length equal to the number of groups

fig_lab

figure panel labels; should be a character vector with length equal to the number of panels (i.e., the number of unique values of by or length one if by was not given)

col.ci

color for individual curves or for all curves in a plot if by is given and map.col = TRUE; if col.ci is a named vector which matches the group labels, then colors are mapped to the corresponding groups; see ciplot

map.col

logical; if TRUE, col.ci will be the color of all curves in each plot (only used when by is non-missing)

time

character string of the time variable (optional)

add

logical; if FALSE (default), resets graphical parameters to settings before ciplot_by was called; set to TRUE for adding to existing plots

plot

logical; if FALSE, no plot is created but a list with cuminc2 object(s) is returned

...

additional arguments passed to ciplot or graphical parameters subsequently passed to par

Value

Invisibly returns a list of cuminc2 object(s) used to generate plot(s). If by was used, there will be a list element for each unique value.

See Also

ciplot; cuminc2; cuminc

Examples

## basic usage: Surv(time, event) ~ 1
ciplot_by(time = 'futime', event = 'event', data = transplant)

## with groups: Surv(time, event) ~ group
ciplot_by('sex', time = 'futime', event = 'event',
          data = transplant)

ciplot_by('sex', time = 'futime', event = 'event',
          data = transplant, by = 'abo', single = FALSE)

par(mfrow = c(1, 2))
ciplot_by('sex', time = 'futime', event = 'event',
          data = transplant, by = 'sex', xlim = c(0, 1500),
          single = FALSE, events.total = 2100)


raredd/cmprsk2 documentation built on March 29, 2024, 5:34 a.m.