I have produced two different plots based on two different models: fit1 and fit2. I want to attach the two plots, but I can not know how to do that.
df %>% filter(category_LVEF == 0) -> df1
df %>% filter(category_LVEF == 1) -> df2
install.packages("rms")
library(rms)
library(survival)
install.packages("datadist")
ddist1 <- datadist(df1)
options(datadist='ddist1')
fit1 <- cph(Surv(`time`, death) ~ rcs(heart rate, 4) + category_Age + category_BP + category_BUN + category_Na + copd, data = df1, nk = 5)
plot(Predict(fit1, heart rate), xlab = "heart rate", ylab = "Relative Risk", lty = 1, lwd = 2)
plot(Predict(fit1, heart rate, ref.zero = TRUE, fun = exp))
ddist2 <- datadist(df2)
options(datadist='ddist2')
fit2 <- cph(Surv(`time`, death) ~ rcs(heart rate, 4) + category_Age + category_BP + category_BUN + category_Na + copd, data = df2, nk = 5)
plot(Predict(fit2, heart rate), xlab = "heart rate", ylab = "Relative Risk", lty = 1, lwd = 2)
plot(Predict(fit2, heart rate, ref.zero = TRUE, fun = exp))
fit1
fit2
If you want tested code, then offer a version of df1. That said, the way to approach plotting problems for situations more complex than what the authors anticipated is to to first figure out what plotting paradigm is being used and then to see if there are additional parameters in base graphics like
ylim
andadd=TRUE
that will let you expand the range and overly graphic elements. If ggplot2 is the paradigm then obviously you will be using+
and the appropriate additonal functions for those operations.