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

surv_summary(x, data = NULL)

## Arguments

x an object of class survfit. 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.

## 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
#> 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 1884.796   57.33119 1896.0
#> rx=Obs, adhere=1          94    94      94     58 1611.102  138.22808 1031.0
#> rx=Lev, adhere=0         522   522     522    269 1890.034   60.48272 2012.0
#> rx=Lev, adhere=1          98    98      98     64 1642.734  125.01246 1161.5
#> rx=Lev+5FU, adhere=0     530   530     530    203 2285.457   55.43665     NA
#> rx=Lev+5FU, adhere=1      78    78      78     39 1946.302  152.86022 2174.0
#>                      0.95LCL 0.95UCL