2

Say I have the following program in R to generate a LaTeX longtable:

library(xtable)
tabela <- xtabs(Temp ~ Month, airquality)
xtabela <- xtable(tabela)
print.xtable(xtabela, tabular.environment = 'longtable', floating = FALSE)

Which yields

\begin{longtable}{rr}
  \hline
 & Month \\ 
  \hline
5 & 2032.00 \\ 
  6 & 2373.00 \\ 
  7 & 2601.00 \\ 
  8 & 2603.00 \\ 
  9 & 2307.00 \\ 
   \hline
\hline
\end{longtable}

However, I want this table to be completely aligned to the right. In LaTeX, I just need to use \begin{longtable}[r]{rr} in order to accomplish this, but how do I pass this [r] argument through R's print.xtable? Alternatively, how do I achieve the same result through other methods (I've tried \raggedleft, but it only works with regular tabular objects)?

Waldir Leoncio
  • 10,853
  • 19
  • 77
  • 107

1 Answers1

1

As a very rough method, you could do:

cat(paste(c("\\begin{longtable}[r]{", align(xt), "}\n"), collapse=""))
print(xtabella, only.contents=T)    
cat("\\end{longtable}\n")
martin
  • 3,149
  • 1
  • 24
  • 35