Below is a sample code:
set.seed(2)
failure_time <- rexp(100)
status <- factor(sample(0:3, 100, replace=TRUE), 0:3,
c('no event', 'death', 'progression','other'))
disease <- factor(sample(1:6, 100,replace=TRUE), 1:6,
c('BRCA','LUNG','OV','CANCER','AIDS','HEART'))
fit <- cuminc(ftime = failure_time, fstatus = status,
group = disease)
ggcompetingrisks(fit)
R automatically generations a plot that is organized in 3 columns, 2 rows. I would like it to be arranged as two columns, and three rows. Is there a way to do with ggcompetingrisks, or would I have to plot everything from scratch?
There is no option that does this that I'm aware of. Meaning you should change the functions code:
Call function code with:
trace(survminer:::ggcompetingrisks.cuminc, edit = T)
On line 23 add ncol = 2
, to facet_wrap(~group)
like:
pl <- ggplot(df, aes(time, est, color = event)) + facet_wrap(~group, ncol = 2)
plot normally:
ggcompetingrisks(fit)