extract_strata: Extract strata from a tidied survival object

Description Usage Arguments Examples

View source: R/extract-strata.R

Description

The tidied results of a survival object are in

Usage

1
extract_strata(tbl, column, ...)

Arguments

tbl

A table

column

Column to extract. Should be of the form col1=val1, col2=val2, ...

...

Extra arguments passed on to extract, such as remove or convert.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(survival)
library(broom)

surv_td <- survfit(Surv(stop - start, status) ~ sex + pcdx,
                    data = mgus1) %>%
  tidy()

surv_td

# Extract into "sex" and "pcdx" columns
surv_fit %>%
  extract_strata(strata)

# Now visualize, separating by strata
library(ggplot2)
surv_fit %>%
  extract_strata(strata) %>%
  ggplot(aes(time, estimate, color = sex)) +
  geom_line() +
  geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) +
  facet_wrap(~ pcdx)

dgrtwo/drlib documentation built on Oct. 11, 2019, 6:42 a.m.