Cox regression output in xtable - choosing rows/columns and adding a confidence interval

后端 未结 2 2048
孤街浪徒
孤街浪徒 2021-02-06 12:06

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(s         


        
2条回答
  •  难免孤独
    2021-02-06 12:49

    xtable(round(summary(fit.pbc)$conf.int[c(1,3),],3))
    #-----------------------------#
    % latex table generated in R 2.13.1 by xtable 1.5-6 package
    % Sat Oct 15 18:36:04 2011
    \begin{table}[ht]
    \begin{center}
    \begin{tabular}{rrrrr}
      \hline
     & exp(coef) & exp(-coef) & lower .95 & upper .95 \\ 
      \hline
    age & 1.04 & 0.96 & 1.02 & 1.06 \\ 
      log(bili) & 2.37 & 0.42 & 2.02 & 2.79 \\ 
       \hline
    \end{tabular}
    \end{center}
    \end{table}
    

    This shows what you see with str on the summary-object

    str(summary(fit.pbc))
    # snipped
     $ conf.int    : num [1:5, 1:4] 1.0404 2.4505 2.3716 10.8791 0.0815 ...
      ..- attr(*, "dimnames")=List of 2
      .. ..$ : chr [1:5] "age" "edema" "log(bili)" "log(protime)" ...
      .. ..$ : chr [1:4] "exp(coef)" "exp(-coef)" "lower .95" "upper .95"
    

提交回复
热议问题