plotKM: Plots a Kaplan Meier survival curve with number at risk table

View source: R/plotKM.R

plotKMR Documentation

Plots a Kaplan Meier survival curve with number at risk table

Description

Creates Kaplan-Meier survival curves, prints a number at risk table and calculates & plots a Cox-PH LRT p-value. Median event times are indicted by addiditional lines.

Usage

plotKM(
  srv,
  grp,
  xlim = NULL,
  col = NULL,
  xyleg = NULL,
  offsetNRisk = -0.2,
  yDelta = 0.1,
  nRiskCat = 4,
  pval = NULL,
  mar = NULL,
  subject = NULL,
  dist = NULL,
  MDPI = F,
  ...
)

Arguments

srv

Survival obejct as obtained by survival::Surv()

grp

grouping variable

xlim

xlim range to plot. Default: 0-max time included in the srv object

xyleg

vector contaning x,y coordinates to the legend

offsetNRisk

offset in y dimensions to move the number at risk table

yDelta

y difference between rows of the number at risk table

nRiskCat

Number of breaks of the number a risk table

pval

xy coordinates of where to plot the pvalue

mar

margin parameter, calculated internally (default). Not used if mar is set to anything different from NULL

MDPI

if set to T, adhere to MDPI requirements

Examples

require(survival)
time <- c(10,7,8,4,11,14)
status <- c(1,1,1,0,1,0)
srv <- Surv(time, status)
	grp <- c(rep("A", 3), rep("B", 3))
	plotKM(srv, grp)

mknoll/dataAnalysisMisc documentation built on Nov. 17, 2024, 9:40 a.m.