knitr::opts_chunk$set(echo = TRUE, results='asis', warning = FALSE, message = FALSE) help_console <- function(topic, format=c("text", "html", "latex", "Rd"), lines=NULL, before=NULL, after=NULL) { format=match.arg(format) if (!is.character(topic)) topic <- deparse(substitute(topic)) helpfile = utils:::.getHelpFile(help(topic)) hs <- capture.output(switch(format, text=tools:::Rd2txt(helpfile), html=tools:::Rd2HTML(helpfile), latex=tools:::Rd2latex(helpfile), Rd=tools:::prepare_Rd(helpfile) ) ) if(!is.null(lines)) hs <- hs[lines] hs <- c(before, hs, after) cat(hs, sep="\n") invisible(hs) }
rm(list =ls()) options(knitr.kable.NA = '.') packs <- c("knitr" ,"survival" ,"devtools" ,"ggplot2" ,"htmlTable" ,"pammtools" ) install <- lapply(packs, function(x) require(x, character.only = T)) install_github("lisaerein/nicesurv") library(nicesurv) help(ggsurv)
data(veteran) head(veteran)
mysfit <- survfit(Surv(time, status) ~ trt, data = veteran) plot(mysfit)
ggsurv(sfit = mysfit)
ggsurv(sfit = mysfit, grname = "Treatment", groups = c(2,1), grlabs = c("Experimental", "Standard"), surv.col = c("black", "darkgray"), surv.lty = c(2,1))
ggsurv(sfit = mysfit, grname = "Treatment", groups = c(2,1), grlabs = c("Experimental", "Standard"), surv.col = c("black", "darkgray"), surv.lty = c(2,1), xlab = c("Days"), xlim = c(0, 360), xby = 30, perc = TRUE)
ggsurv(sfit = mysfit, grname = "Treatment", groups = c(2,1), grlabs = c("Experimental", "Standard"), surv.col = c("black", "darkgray"), surv.lty = c(2,1), xlab = c("Days"), xlim = c(0, 360), xby = 30, perc = TRUE, ci = FALSE)
ggsurv(sfit = mysfit, grname = "Treatment", groups = c(2,1), grlabs = c("Experimental", "Standard"), surv.col = c("black", "darkgray"), surv.lty = c(1,1), xlab = c("Days"), xlim = c(0, 360), xby = 30, perc = TRUE, ci = FALSE, grid = FALSE, risktab = TRUE, risktab.margins = c(0,0.01,0.2,0.15), risktab.times = c(0,30,60,120,180,240,300,360))
mysfit2 <- survfit(Surv(time, status) ~ 1, data= veteran) ggsurv(sfit = mysfit2, grid = c(FALSE, TRUE), ci.ribbon = FALSE, ci.lty = 2, ci.size = 0.5, cens = FALSE, xlab = "\nMonths", xlim = c(0,3)*360, xby = 90, xbrlabs = seq(0,36,3), risktab = T, risktab.margins = c(0,0.01,0.2,0.15), risktab.times = seq(0,360*3,90))
mt <- medtab(mysfit, printorig = FALSE) mt <- medtab(mysfit, groups = c(2,1), grlabs = c("Experimental", "Standard"), printorig = FALSE)
st <- survtab(mysfit, times = c(0,30,120,360,500), surv.dec = 2, groups = c(1,2), grlabs = c("Std.", "Exp."), printorig = FALSE)
coxmod <- coxph(Surv(time, status) ~ trt + celltype + karno, data= veteran) coxtbl <- nicecoxph(coxmod)
coxmod <- coxph(Surv(time, status) ~ trt + celltype + karno, data= veteran) coxtbl <- nicecoxph(df = veteran, covs = c("trt", "celltype", "karno"), ttevent = "time", event = "status", type3 = TRUE, regtype = "uni")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.