km: Plots an 'enhanced' Kaplan-Meier plot, with base graphics...

View source: R/km.R

kmR Documentation

Plots an 'enhanced' Kaplan-Meier plot, with base graphics package.

Description

This function plots a Kaplan-Meier plot.

Usage

km(
  time = NULL,
  status = NULL,
  strata = NULL,
  plot = TRUE,
  time_unit = c("days", "weeks", "months", "years"),
  time_by = NULL,
  quantile_probs = 0.5,
  main = "",
  ylab = NULL,
  xlab = NULL,
  ylim = c(0L, 1L),
  xlim = NULL,
  reverse = FALSE,
  mark_censored = TRUE,
  pch_censored = "'",
  conf_int = c("default", "none", "lines", "shades"),
  conf_int_alpha = 0.8,
  test = c("logr", "hr", "both", "none"),
  cex_test = par("cex") * 0.8,
  plot_grid = TRUE,
  plot_n_at_risk = TRUE,
  cex_n_at_risk = par("cex") * 0.8,
  legend_cmd = NULL,
  ...
)

Arguments

time

survival time variable

status

survival indicator variable

strata

Stratifying variable (optional)

plot

plot (default = TRUE) or only return estimates?

time_unit

Time unit of x axis

time_by

Time step x axis (in days)

quantile_probs

quantile calculated (default to 0.5, aka median)

main

Graph main title

ylab

Y-axis label.

xlab

X-axis label. If NULL a suitable default based on time_unit will be provided

ylim

Y-axis limit. Default to c(0,1) be provided

xlim

X-axis limit. If NULL a suitable default based on time_unit will be provided

reverse

plot cumulative events

mark_censored

mark censored observation

pch_censored

pch used for censored observation

conf_int

character. Can be 'default', 'none' or 'lines' or 'shades'

conf_int_alpha

a base level for alpha if conf_int = 'alpha' (splitted by number of groups)

test

tests: 'none' = don't plot tests, 'logr' = log-rank test, 'hr' = hazard ratio, 'both' = log-rank test and hazard ratio

cex_test

cex parameter for test string

plot_grid

plot grid

plot_n_at_risk

Logical value: plot number at risk?

cex_n_at_risk

cex of number at risk

legend_cmd

Graph command to add legend, as string

...

Further lines.survfit parameters

Details

The function make the hypothesis that times are measured in days; in not leave time_unit not specified

Value

The function plot the graph and return a list with Laplan-Meier statistics

Examples

library(survival)
km(time = aml$time, status = aml$status, strata = aml$x)

lbraglia/lbsurv documentation built on June 19, 2022, 11:13 p.m.