I wan't to export the output from a cox regression to a table that I then can put into my article. I guess the best way to go about it is with xtable:
library(survival)
data(pbc)
fit.pbc <- coxph(Surv(time, status==2) ~ age + edema + log(bili) +
log(protime) + log(albumin), data=pbc)
summary(fit.pbc)
library(xtable)
xtable(fit.pbc)
Now I want to do the following to the output:
- Add confidence interval (CI) of 95 %
- Select certain rows, say age and log(protime)
- Round the exp(B) & CI to three decimals
- Remove the column with z & regular coef
Thanks in advance!
This shows what you see with str on the summary-object
I'd approach this by first taking a look at how the
survival
package constructs the table it prints by default.To find the function that does that printing, examine the class of your fit object, and then look for a print method for that class:
After taking a look at
print.coxph
, here's what I came up with: