| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/survival-survfit.R |
| 3 |
\name{tidy.survfit} |
| 4 |
\alias{tidy.survfit} |
| 5 |
\alias{survfit_tidiers} |
| 6 |
\title{Tidy a(n) survfit object} |
| 7 |
\usage{ |
| 8 |
\method{tidy}{survfit}(x, ...) |
| 9 |
} |
| 10 |
\arguments{ |
| 11 |
\item{x}{An \code{survfit} object returned from \code{\link[survival:survfit]{survival::survfit()}}.} |
| 12 |
|
| 13 |
\item{...}{For \code{glance.survfit()}, additional arguments passed |
| 14 |
to \code{\link[=summary]{summary()}}. Otherwise ignored.} |
| 15 |
} |
| 16 |
\description{ |
| 17 |
Tidy summarizes information about the components of a model. |
| 18 |
A model component might be a single term in a regression, a single |
| 19 |
hypothesis, a cluster, or a class. Exactly what tidy considers to be a |
| 20 |
model component varies across models but is usually self-evident. |
| 21 |
If a model has several distinct types of components, you will need to |
| 22 |
specify which components to return. |
| 23 |
} |
| 24 |
\examples{ |
| 25 |
\dontshow{if (rlang::is_installed(c("survival", "ggplot2"))) withAutoprint(\{ # examplesIf} |
| 26 |
|
| 27 |
# load libraries for models and data |
| 28 |
library(survival) |
| 29 |
|
| 30 |
# fit model |
| 31 |
cfit <- coxph(Surv(time, status) ~ age + sex, lung) |
| 32 |
sfit <- survfit(cfit) |
| 33 |
|
| 34 |
# summarize model fit with tidiers + visualization |
| 35 |
tidy(sfit) |
| 36 |
glance(sfit) |
| 37 |
|
| 38 |
library(ggplot2) |
| 39 |
|
| 40 |
ggplot(tidy(sfit), aes(time, estimate)) + |
| 41 |
geom_line() + |
| 42 |
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) |
| 43 |
|
| 44 |
# multi-state |
| 45 |
fitCI <- survfit(Surv(stop, status * as.numeric(event), type = "mstate") ~ 1, |
| 46 |
data = mgus1, subset = (start == 0) |
| 47 |
) |
| 48 |
|
| 49 |
td_multi <- tidy(fitCI) |
| 50 |
|
| 51 |
td_multi |
| 52 |
|
| 53 |
ggplot(td_multi, aes(time, estimate, group = state)) + |
| 54 |
geom_line(aes(color = state)) + |
| 55 |
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) |
| 56 |
\dontshow{\}) # examplesIf} |
| 57 |
} |
| 58 |
\seealso{ |
| 59 |
\code{\link[=tidy]{tidy()}}, \code{\link[survival:survfit]{survival::survfit()}} |
| 60 |
|
| 61 |
Other survival tidiers: |
| 62 |
\code{\link{augment.coxph}()}, |
| 63 |
\code{\link{augment.survreg}()}, |
| 64 |
\code{\link{glance.aareg}()}, |
| 65 |
\code{\link{glance.cch}()}, |
| 66 |
\code{\link{glance.coxph}()}, |
| 67 |
\code{\link{glance.pyears}()}, |
| 68 |
\code{\link{glance.survdiff}()}, |
| 69 |
\code{\link{glance.survexp}()}, |
| 70 |
\code{\link{glance.survfit}()}, |
| 71 |
\code{\link{glance.survreg}()}, |
| 72 |
\code{\link{tidy.aareg}()}, |
| 73 |
\code{\link{tidy.cch}()}, |
| 74 |
\code{\link{tidy.coxph}()}, |
| 75 |
\code{\link{tidy.pyears}()}, |
| 76 |
\code{\link{tidy.survdiff}()}, |
| 77 |
\code{\link{tidy.survexp}()}, |
| 78 |
\code{\link{tidy.survreg}()} |
| 79 |
} |
| 80 |
\concept{survfit tidiers} |
| 81 |
\concept{survival tidiers} |
| 82 |
\value{ |
| 83 |
A \code{\link[tibble:tibble]{tibble::tibble()}} with columns: |
| 84 |
\item{conf.high}{Upper bound on the confidence interval for the estimate.} |
| 85 |
\item{conf.low}{Lower bound on the confidence interval for the estimate.} |
| 86 |
\item{n.censor}{Number of censored events.} |
| 87 |
\item{n.event}{Number of events at time t.} |
| 88 |
\item{n.risk}{Number of individuals at risk at time zero.} |
| 89 |
\item{std.error}{The standard error of the regression term.} |
| 90 |
\item{time}{Point in time.} |
| 91 |
\item{estimate}{estimate of survival or cumulative incidence rate when |
| 92 |
multistate} |
| 93 |
\item{state}{state if multistate survfit object input} |
| 94 |
\item{strata}{strata if stratified survfit object input} |
| 95 |
|
| 96 |
} |