ggplot.npsurv: Title Plot npsurv Nonparametric Survival Curves Using ggplot2

View source: R/ggplot.npsurv.r

ggplot.npsurvR Documentation

Title Plot npsurv Nonparametric Survival Curves Using ggplot2

Description

Title Plot npsurv Nonparametric Survival Curves Using ggplot2

Usage

## S3 method for class 'npsurv'
ggplot(
  data,
  mapping,
  conf = c("bands", "none"),
  trans = c("identity", "logit", "probit", "loglog"),
  logt = FALSE,
  curtail = c(0, 1),
  xlab,
  ylab = "Survival Probability",
  abbrev.label = FALSE,
  levels.only = TRUE,
  alpha = 0.15,
  facet = FALSE,
  npretty = 10,
  onlydata = FALSE,
  ...,
  environment
)

Arguments

data

the result of npsurv

mapping

unused

conf

set to "none" to suppress confidence bands

trans

the name of a transformation for the survival probabilities to use in drawing the y-axis scale. The default is no transformation, and other choices are ⁠"logit", "probit", "loglog"⁠. "loglog" represents -log(-log(S(t)))

logt

set to TRUE to use a log scale for the x-axis

curtail

set to a (lower, upper) 2-vector to curtail survival probabilities and confidence limits before transforming and plotting

xlab

x-axis label, the default coming from fit

ylab

y-axis label, the default coming from fit

abbrev.label

set to TRUE to abbreviate strata levels

levels.only

set to FALSE to keep the original strata name in the levels

alpha

transparency for confidence bands

facet

when strata are present, set to TRUE to facet them rather than using colors on one panel

npretty

the number of major tick mark labels to be constructed by scales::breaks_pretty() or pretty(). For transformed scales, twice this number is used.

onlydata

set to TRUE to return the data frame to be plotted, and no plot

...

ignored

environment

unused

Value

a ggplot2 object, if onlydata=FALSE

Author(s)

Frank Harrell

Examples

set.seed(1)
g <- c(rep('a', 500), rep('b', 500))
y <- exp(-1 + 2 * (g == 'b') + rlogis(1000) / 3)
f <- npsurv(Surv(y) ~ g)
ggplot(f, trans='logit', logt=TRUE)

rms documentation built on April 12, 2025, 1:18 a.m.