I would approach this by first looking at how the survival
package creates a table that it prints by default.
To find the function that performs this printing, examine the fit object class and then find the print method for this class:
class(fit.pbc) # [1] "coxph" grep("coxph", methods("print"), value=TRUE) # [1] "print.coxph" "print.coxph.null" # [3] "print.coxph.penal" "print.summary.coxph"
Looking at print.coxph
, here is what I came up with:
cox <- fit.pbc # Prepare the columns beta <- coef(cox) se <- sqrt(diag(cox$var)) p <- 1 - pchisq((beta/se)^2, 1) CI <- round(confint(cox), 3) # Bind columns together, and select desired rows res <- cbind(beta, se = exp(beta), CI, p) res <- res[c("age", "log(protime)"),] # Print results in a LaTeX-ready form xtable(res)
source share