Skip to contents

Compared to the default summary() function, surv_summary() creates a data frame containing a nice summary from survfit results.

Usage

surv_summary(x, data = NULL)

Arguments

x

an object of class survfit.

data

a dataset used to fit survival curves. If not supplied then data will be extracted from 'fit' object.

Value

An object of class 'surv_summary', which is a data frame with the following columns:

  • time: the time points at which the curve has a step.

  • n.risk: the number of subjects at risk at t.

  • n.event: the number of events that occur at time t.

  • n.censor: number of censored events.

  • surv: estimate of survival.

  • std.err: standard error of survival.

  • upper: upper end of confidence interval.

  • lower: lower end of confidence interval.

  • strata: stratification of survival curves.

In a situation, where survival curves have been fitted with one or more variables, surv_summary object contains extra columns representing the variables. This makes it possible to facet the output of ggsurvplot by strata or by some combinations of factors.

surv_summary object has also an attribut named 'table' containing information about the survival curves, including medians of survival with confidence intervals, as well as, the total number of subjects and the number of event in each curve.

Author

Alboukadel Kassambara, alboukadel.kassambara@gmail.com

Examples


# Fit survival curves
require("survival")
fit <- survfit(Surv(time, status) ~ rx + adhere, data = colon)

# Summarize
res.sum <- surv_summary(fit, data = colon)
head(res.sum)
#>   time n.risk n.event n.censor      surv     std.err     upper     lower
#> 1   20    536       1        0 0.9981343 0.001867414 1.0000000 0.9944878
#> 2   43    535       1        0 0.9962687 0.002643394 1.0000000 0.9911204
#> 3   45    534       1        0 0.9944030 0.003240519 1.0000000 0.9881072
#> 4   59    533       1        0 0.9925373 0.003745345 0.9998501 0.9852780
#> 5   72    532       1        0 0.9906716 0.004191364 0.9988435 0.9825667
#> 6   77    531       1        0 0.9888060 0.004595738 0.9977529 0.9799393
#>             strata  rx adhere
#> 1 rx=Obs, adhere=0 Obs      0
#> 2 rx=Obs, adhere=0 Obs      0
#> 3 rx=Obs, adhere=0 Obs      0
#> 4 rx=Obs, adhere=0 Obs      0
#> 5 rx=Obs, adhere=0 Obs      0
#> 6 rx=Obs, adhere=0 Obs      0

# Information about the survival curves
attr(res.sum, "table")
#>                      records n.max n.start events    rmean se(rmean) median
#> rx=Obs, adhere=0         536   536     536    287 1912.669  58.86910 1896.0
#> rx=Obs, adhere=1          94    94      94     58 1636.353 141.50567 1031.0
#> rx=Lev, adhere=0         522   522     522    269 1918.275  62.46927 2012.0
#> rx=Lev, adhere=1          98    98      98     64 1663.018 128.24939 1161.5
#> rx=Lev+5FU, adhere=0     530   530     530    203 2325.520  56.89176     NA
#> rx=Lev+5FU, adhere=1      78    78      78     39 1978.328 156.62393 2174.0
#>                      0.95LCL 0.95UCL
#> rx=Obs, adhere=0        1447    2351
#> rx=Obs, adhere=1         726    2077
#> rx=Lev, adhere=0        1298      NA
#> rx=Lev, adhere=1         851    1895
#> rx=Lev+5FU, adhere=0      NA      NA
#> rx=Lev+5FU, adhere=1     993      NA