Export/format output from pairwise.t.test to LaTeX I am trying to format the output from pairwise.t.test into LaTeX, but have not found a way of doing this. Has anyone got any suggestions? 
EDIT: As this is a one-time only report where I do need to customize the variable names, and row-/column headings, I was hoping to avoid using Sweave.
 A: Does this help?
> library(xtable)
> attach(airquality)
> res <- pairwise.t.test(Ozone, Month)
> xtable(res$p.value, caption=res$method)
% latex table generated in R 2.9.2 by xtable 1.5-6 package
% Mon Aug 16 04:24:21 2010
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrr}
  \hline
 & 5 & 6 & 7 & 8 \\ 
  \hline
6 & 1.00 &  &  &  \\ 
  7 & 0.00 & 0.05 &  &  \\ 
  8 & 0.00 & 0.05 & 1.00 &  \\ 
  9 & 1.00 & 1.00 & 0.00 & 0.00 \\ 
   \hline
\end{tabular}
\caption{t tests with pooled SD}
\end{center}
\end{table}

A: One way that you can do the above task without using Sweave is as follows: 


*

*Write a custom export function from R that takes the pairwise.t.test object and outputs latex code.

*Use \input{...} in your LaTeX document to input this file into your LaTeX document.


With regards to step 1, there are many functions that are useful. Here are a few:


*

*paste() is useful for concatenating elements including latex elements with R objects

*formatC() is useful for formatting numbers

*write() is useful for exporting the combined LaTeX/R character vector from R to a text file


There are also a variety of LaTeX table generating functions (e.g., see the xtable package)
