Search code examples
rlatexxtable

How to remove "Standard Error" column from xtable() output of an lm on R/RSweave/LaTeX


I'm currently doing some data analysis on population data, so reporting the standard errors in the tables of parameter coefficients just doesn't really make statistical sense. I've done a fair bit of searching and can't find any way to customize the xtable output to remove it. Can anyone point me in the right direction?

Thanks a lot, I didn't post this lightly; if it's something obvious, I apologize for having wasted time!


Solution

  • so after my (other) whole long-winded answer... this works too:

    xtable(summary(model1)$coefficients[,c(1,3,4)])
    

    Or more generically:

    sm <- summary(SomeModel)
    SE.indx <- which(colnames(sm$coefficients) == "Std. Error")   # find which column is Std. Error (usually 2nd)
    sm$coefficients <- sm$coefficients[, -SE.indx]  # Remove it
    xtable(sm$coefficients)   # call xtable on just the coefficients table
    

    Results:

    % latex table generated in R 2.15.1 by xtable 1.7-0 package
    % Sun Dec  9 00:01:46 2012
    \begin{table}[ht]
    \begin{center}
    \begin{tabular}{rrrr}
      \hline
     & Estimate & t value & Pr($>$$|$t$|$) \\ 
      \hline
    (Intercept) & 29.80 & 30.70 & 0.00 \\ 
      crim & -0.31 & -6.91 & 0.00 \\ 
      age & -0.09 & -6.50 & 0.00 \\ 
       \hline
    \end{tabular}
    \end{center}
    \end{table}