0

I would like to get a table formatted like this:

enter image description here

I have used "xtable" but I don´t understand how to get it from the print(table) command:

   > test
% latex table generated in R 3.2.3 by xtable 1.8-0 package
% 
\begin{tabular}{lrrrrr}
\hline
& Df & Sum Sq & Mean Sq & F value & Pr($>$F) \\ 
\hline
Ws & 1 & 31680.42 & 31680.42 & 229.58 & 0.0000 \\ 
Pht & 2 & 11105.78 & 5552.89 & 40.24 & 0.0000 \\ 
Location & 12 & 58471.70 & 4872.64 & 35.31 & 0.0000 \\ 
Room & 1 & 5802.30 & 5802.30 & 42.05 & 0.0000 \\ 
Residuals & 8479 & 1170043.80 & 137.99 &  &  \\ 
\hline
\end{tabular}

dput(test)

structure(list(Df = c(1L, 2L, 12L, 1L, 8479L), Sum Sq = c(31680.4185499081, 11105.7770715626, 58471.7013752211, 5802.30093225522, 1170043.80160024 ), Mean Sq = c(31680.4185499081, 5552.88853578132, 4872.64178126843, 5802.30093225522, 137.993136171747), F value = c(229.579669169041, 40.240324191706, 35.3107546972765, 42.0477502955918, NA), Pr(>F) = c(3.43375691459393e-51, 4.03894428387556e-18, 4.68524863196024e-81, 9.40518972974665e-11, NA)), .Names = c("Df", "Sum Sq", "Mean Sq", "F value", "Pr(>F)" ), row.names = c("Ws", "Pht", "Location", "Room", "Residuals" ), class = c("xtable", "data.frame"), heading = c("Analysis of Variance Table\n", "Response: Leaves"), align = c("l", "r", "r", "r", "r", "r"), digits = c(0, 0, 2, 2, 2, 4), display = c("s", "f", "f", "f", "f", "f"))

Luisa
  • 35
  • 2
  • 12
  • Could you `dput()` your data.frame pls? – vaettchen May 11 '16 at 14:32
  • 1
    Also, how are you building your document? Sweave? rmarkdown? something else? It may be that you need to change a chunk option. – Benjamin May 11 '16 at 14:42
  • I am using Text File – Luisa May 11 '16 at 16:51
  • Luisa, you understand the formated table you show in *not* plain text -- there are lines and formatting. Report generation from R needs a target format, hence Benjamin question. xtable generates LaTeX syntax that may be used to generate a PDF report, for instance through rmardown (cf knitR). I recommend you to have a look at Rstudio help about markdown. – Eric Lecoutre May 14 '16 at 16:16

0 Answers0