I know that there are countless of questions on how to combine plots. However, I have not found a solution that works for my request.
Please, find a Data sample
below.
I have four plots, which all are produced by the same script (but loaded from different data
). I cannot get it to work with par()
when using ggpar
for my ggsurvplot
.
pfs <- survfit(Surv(resp.time, response) ~ 1, data=w)
os <- survfit(Surv(Follow.up.death, Death) ~ 1, data=w)
fit <- list(PFS = pfs, OS = os)
j <- ggsurvplot(fit, data = w, combine = TRUE,
risk.table = TRUE,
conf.int = TRUE,
conf.int.style = "ribbon",
censor = TRUE,
tables.theme = theme,
ggtheme = theme,
xlim = c(0,24),
ylim = c(0.4,1),
legend.labs=c("PFS (All)","OS (All)"),
alpha=0.8,
size=0.7,
conf.int.alpha=c(0.1),
xlab="Months",
break.x.by = 3,
surv.scale="percent",
palette = c("#1C73C2","red"))
ggpar(j, font.x = c(11, "bold", "black"), font.y = c(11, "bold", "black"),font.tickslab = c(11), font.legend = c(12))
So, I produce four different ggpar
-plots and I would like the presented graphically like the demonstrated below
I have tried
ggarrange(aa, bb, cc, dd,
labels = c("A", "B", "C", "D"),
ncol = 2, nrow = 2)
When aa <- ggpar()1
, bb <- ggpar()2
, cc <- ggpar()3
and dd <- ggpar()4
But I receive this warning:
Argument needs to be of class "ggplot", "gtable", "grob", "recordedplot", or a function that plots to an R graphicsdevice when called, but is a ggsurvplotggsurvlist
Here is a sample of my data
# Data sample
w <- structure(list(resp.time = c(18, 2, 13, 17, 22, 2, 6, 5, 12,
8, 3, 2, 1, 21, 2, 43, 4, 2, 4, 5, 0.1, 137, 4, 87, 17, 24, 72,
19, 14, 83, 68, 56, 57, 18, 14, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 15.6, 8.9, 15, 16.4,
7.7, 75.5, 3, 54.8, 22.2, 12, 14.3, 6, 12, 21.8, 6, 3, 12, 3,
6, 3, 3, 12, 9.7, 3, 3, 12, 3, 6, 3, 6, 4, 50, 21, 30, 5, 11,
12, 4, 18, 6, NA, 3), response = c(0L, 1L, 0L, 0L, 0L, 1L, 1L,
1L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0L, 0L,
0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 1L, NA, 1L), Death = c(0L, 1L, 1L, 0L, 0L,
1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L,
1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, NA, 1L), Follow.up.death = c(18,
2, 14, 17, 31, 4, 20, 15, 12, 19, 10, 17, 27, 22, 3, 43, 24,
14, 13, 5, 12, 137, 22, 87, 48, 24, 72, 32, 14, 83, 68, 56, 57,
18, 16, 70, 1.9, 69.2, 126.3, 41.6, 17.9, 1.3, 87.4, 4.4, 137.4,
17.5, 95.8, 65.2, 14.8, 98.5, 16.6, 74.9, 10.3, 43.4, 32.5, 4.8,
7.3, 107.8, 6.8, 18.3, 33, 25.2, 49.2, 15.9, 1.2, 42.7, 1, 9,
1.8, 15.6, 8.9, 15, 16.4, 7.7, 75.5, 12.2, 54.8, 22.2, 9.7, 14.3,
5.2, 64.5, 21.8, 0.2, 7.3, 18.7, 5.1, 17.3, 27.4, 16, 24.2, 9.7,
8.2, 5.7, 41.8, 10.6, 22.8, 4.8, 6, 4, 50, 21, 30, 5, 11, 12,
4, 18, 6, NA, 3)), class = "data.frame", row.names = c(NA, -111L
))
Thank you in advance.