Skip to content
Prev 166411 / 398502 Next

help

Unfortunately a little long

Try this (I have used Miktex 2.7 on win XP and R 2.8 for this)
I have not gone into the detail of the first chunk I just created the 
header strings in R and copied to make the Sweave file lines
With a little thought it can be done I suppose

## Sweave script
\documentclass[10pt,a4paper,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{times}
\usepackage[left=0.5in,right=0.5in,top=1.0in,bottom=1.0in,includefoot]{geometry}
\usepackage{dcolumn}
\usepackage{booktabs}
\usepackage{longtable}

\setlength{\parindent}{0pt}

% BEGIN DOCUMENT
\begin{document}

\begin{small}
\begin{longtable}[34]{rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr}
% if want different first 1
\toprule
\addlinespace[5pt]
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 
18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 & 27 & 28 & 29 & 30 & 31 & 32 & 
33 & 34 \\
\addlinespace[3pt]
\midrule
\addlinespace[5pt]
\endfirsthead

% all table headers (if not first different use \toprule instead on the 
next line)
\midrule
\addlinespace[5pt]
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 
18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 & 27 & 28 & 29 & 30 & 31 & 32 & 
33 & 34 \\
\addlinespace[3pt]
\midrule
\addlinespace[5pt]
\endhead

% last footer
\addlinespace[5pt]
\bottomrule
\endlastfoot

% other footers
\addlinespace[5pt]
\multicolumn{33}{r}{Continued next page}\\
\addlinespace[3pt]
\midrule
\endfoot
%
<<results=tex, echo=F>>=

   library(xtable)
   set.seed(2345)

   res <- matrix(sample(0:9, size=34*90, replace=TRUE), ncol=34, nrow=90)

   x <- apply(res,1,function(x) paste(paste(x,collapse= " & "), "\\\\ \n") )

   for (j in seq_along(x) ) cat(x[j])
@

\end{longtable}
\end{small}

% END DOCUMENT
\end{document}

# end Sweave

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email (home): mackay at northnet.com.au
At 06:30 9/01/2009, you wrote: