View source: R/ggcompetingrisks.R
ggcompetingrisks | R Documentation |
This function plots Cumulative Incidence Curves. For cuminc
objects it's a ggplot2
version of plot.cuminc
.
For survfitms
objects a different geometry is used, as suggested by @teigentler
.
ggcompetingrisks(
fit,
gnames = NULL,
gsep = " ",
multiple_panels = TRUE,
ggtheme = theme_survminer(),
coef = 1.96,
conf.int = FALSE,
...
)
fit |
an object of a class |
gnames |
a vector with group names. If not supplied then will be extracted from |
gsep |
a separator that extracts group names and event names from |
multiple_panels |
if |
ggtheme |
function, |
coef |
see |
conf.int |
if |
... |
further arguments passed to the function |
Returns an object of class gg
.
Przemyslaw Biecek, przemyslaw.biecek@gmail.com
## Not run:
if(require("cmprsk")){
set.seed(2)
ss <- rexp(100)
gg <- factor(sample(1:3,100,replace=TRUE),1:3,c('BRCA','LUNG','OV'))
cc <- factor(sample(0:2,100,replace=TRUE),0:2,c('no event', 'death', 'progression'))
strt <- sample(1:2,100,replace=TRUE)
# handles cuminc objects
print(fit <- cmprsk::cuminc(ss,cc,gg,strt))
ggcompetingrisks(fit)
ggcompetingrisks(fit, multiple_panels = FALSE)
ggcompetingrisks(fit, conf.int = TRUE)
ggcompetingrisks(fit, multiple_panels = FALSE, conf.int = TRUE)
# handles survfitms objects
library(survival)
df <- data.frame(time = ss, group = gg, status = cc, strt)
fit2 <- survfit(Surv(time, status, type="mstate") ~ 1, data=df)
ggcompetingrisks(fit2)
fit3 <- survfit(Surv(time, status, type="mstate") ~ group, data=df)
ggcompetingrisks(fit3)
}
library(ggsci)
library(cowplot)
ggcompetingrisks(fit3) + theme_cowplot() + scale_fill_jco()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.