Skip to content
Prev 307403 / 398506 Next

How to create a table with borders?

Hello,

Why not use package xtable? I've just tried the following.

#install.packages('xtable')
library(xtable)

x <- 1:20
y <- 0.5*x + rnorm(20)

fit <- aov(y ~ x)
latex.tbl <- xtable(fit)
align(latex.tbl) <- "|lrrrrr|"
print(latex.tbl)

The output was

% latex table generated in R 2.15.1 by xtable 1.7-0 package
% Tue Oct 09 08:12:33 2012
\begin{table}[ht]
\begin{center}
\begin{tabular}{|lrrrrr|}
   \hline
  & Df & Sum Sq & Mean Sq & F value & Pr($>$F) \\
   \hline
x & 1 & 191.80 & 191.80 & 208.27 & 0.0000 \\
   Residuals & 18 & 16.58 & 0.92 &  &  \\
    \hline
\end{tabular}
\end{center}
\end{table}


Hope this helps,

Rui Barradas


Em 09-10-2012 04:47, killerkarthick escreveu: