I'm trying to use survminer to create an adjusted survival curve with ggadjustedcurves(). My code is as follows:
adjustedcurve <- coxph(Surv(time_DeathTxCensor, deadORtx==1) ~ strata(natADI_quart) + sex + FVCpctPre + DLCOpctPre + smokeHx + age_dx, data=ADI, id=ID)
ggadjustedcurves(adjustedcurve,
variable="natADI_quart",
method="conditional",
data=ADI)
And I am getting the error message:
Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed
Also here is my traceback:
16. .gt(structure(c(1L, 3L, 2L, 4L), .Label = c("1", "2", "3", "4" ), class = "factor"), 1L, 2L)
15. rank(x, ties.method = "min", na.last = "keep")
14. as.vector(rank(x, ties.method = "min", na.last = "keep"))
13. xtfrm.default(x)
12. xtfrm(x)
11. as.vector(xtfrm(x))
10. FUN(X[[i]], ...)
9. lapply(z, function(x) if (is.object(x)) as.vector(xtfrm(x)) else x)
8. order(x, na.last = na.last, decreasing = decreasing)
7. `[.tbl_df`(x, order(x, na.last = na.last, decreasing = decreasing))
6. x[order(x, na.last = na.last, decreasing = decreasing)]
5. sort.default(unique(data[, variable]))
4. sort(unique(data[, variable]))
3. ggadjustedcurves.conditional(data, fit, variable, size = size)
2. surv_adjustedcurves(fit = fit, variable = variable, data = data, reference = reference, method = method, size = size, ...)
1. ggadjustedcurves(adjustedcurve, data = ADI)
I have no idea what this means or how to fix it. Would really appreciate any help :)