fplot.surv: Plot Kaplan-Meier Curves with number at risk and number...

View source: R/fplot.surv.R

fplot.survR Documentation

Plot Kaplan-Meier Curves with number at risk and number censored at bottom

Description

Plot Kaplan-Meier Curves with number at risk and number censored at bottom

Usage

fplot.surv(smdl.yt = "Mths.OS", smdl.ye = "OS", smdl.x = "",
  xnames = "", xlab = "Months", ylab = "Overall Survival (%)",
  dat = dat.work, t.at = NULL, lty = 1, mar = c(4, 3.5, 0.5, 0.5),
  mgp = c(2, 0.8, 0), nr.line = 3, nr.xadj = 0.75, nr.yadj = 0.8,
  loc.legend = "bottomleft", loc.p = "topright")

Arguments

smdl.yt

survival time

smdl.ye

event

smdl.x

a covariate

xnames

group names of the covariate x

xlab

label of x-axis

ylab

label of y-axis

dat

data

t.at

location of the x-axis tick marks

mar

margin parameters

mgp

mgp parameters

nr.line

lines from the x-axis for the number at risk texts

nr.xadj

adjustment along x-axis for the NR(NC) notation as a fraction of the length of the second tick mark from 0

nr.yadj

adjustment along y-axis for the NR(NC) notation

loc.legend

location of the legend

loc.p

location of the p-value

Value

survfit output, median survival and coxph output if there is a covariate x

Examples

set.seed(16)
dat.work <- data.frame(StudyID=1:40,
                       Death = sample(c(0,1), 40, replace=T, p=c(0.2, 0.8)),
                       Mths.OS = 10*rexp(40, rate=0.5),
                       Group = factor(rep(c("grp1", "grp2"), c(15,25))))
out <- fplot.surv(smdl.yt = "Mths.OS",
                  smdl.ye = "Death",
                  xlab = "Months",
                  ylab = "Overall Survival (%)",
                  dat = dat.work,
                  mar=c(4.0,3.5,0.5,0.7),
                  mgp = c(2.0, 0.8, 0),
                  nr.line = 3,
                  nr.xadj = 0.4,
                  nr.yadj = 0.8)

out <- fplot.surv(smdl.yt = "Mths.OS",
                  smdl.ye = "Death",
                  smdl.x = "Group",
                  xnames = c("Group1", "Group2"),
                  xlab = "Months",
                  ylab = "Overall Survival (%)",
                  dat=dat.work,
                  t.at = NULL,
                  lty=NULL,
                  mar = c(4.0,3.5,0.5,0.7),
                  mgp = c(2.0, 0.8, 0),
                  nr.line = 3,
                  nr.xadj = 0.4,
                  nr.yadj = 0.8,
                  loc.legend = "bottomleft",
                  loc.p = "topright")


xkzhou/BTKR documentation built on Feb. 1, 2023, 1:14 a.m.