createSurvivalFrame: Create a data frame suitable for plotting survival curves...

Description Usage Arguments Value References Examples

View source: R/CreateSurvivalFrame.R

Description

createSurvivalFrame Create a data frame suitable for plotting survival curves from a 'survfit' object.

Usage

1

Arguments

Sfit

A object from survfit

Value

A dataframe suitable for plotting survival curves

References

code written by Ramon Saccilotto

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
s1 <- survfit(Surv(as.numeric(D$surdate), D$censor_m) ~ D$isup_m, data = D)
f.frame<-createSurvivalFrame(s1)

ggplot(data=f.frame, aes(col = strata, group = strata)) + geom_step(aes(x = time, y = surv), direction = "hv", size = 1.2) +
       geom_point(data = subset(f.frame, n.censor == 1), aes(x = time, y = surv), shape = "|", cex = 7) + theme_bw() +
       scale_color_discrete(name="  ",
                            breaks = c("D$isup_m=1", "D$isup_m=2","D$isup_m=3", "D$isup_m=4"),
                            labels = c("1", "2", "3", "4")) +
       scale_x_discrete(breaks = c(seq(0, 30, by=5)), labels = c(seq(0, 30, by=5))) +
       coord_cartesian(ylim = c(0, 1.05)) +
       theme(axis.text = element_text(size = 18),
             axis.title = element_text(size = 16,face = "bold"),
             plot.title = element_text(lineheight = .12, face = "bold", size = 15),
             legend.text = element_text(size = 18)) +
       labs(x = "
                 Time (Month)", y = "Survival
              ",size = rel(2))+
       ggtitle("(a) ISUP Grouping



      ")

SophiaJia/Jsurvformat1.2 documentation built on May 10, 2017, 2:33 p.m.