[R] merge table rows (\multirow)

Felipe Carrillo mazatlanmexico at yahoo.com
Mon Jan 12 06:41:19 CET 2009


Hi:
I need help merging rows.
I am trying to merge the 'Month' column using \multirow. For example for the column 'Week' I want July to be merged into one row(weeks 27,28,29,30) and so on for the following weeks.
Below, I am creating a PDF using Sweave, MikTex,R-2.8.1 and windows XP to show an example.


\documentclass[11pt]{article}
\usepackage{longtable,verbatim}
\title{How to implement multirow with Sweave}
\begin{document}
\maketitle
<<dataAnalysis.R,echo=FALSE>>=
sampDat <- "Month, Week, Est.passage, Med.FL
July 27	   665	         34
July 28	   2,232	       35
July 29	   9,241	       35
July 30	   28,464	       35
Aug  31	   41,049	       35
Aug 32	   82,216	       35
Aug 33	   230,411      35
Aug 34	   358,541      35
Sept 35	   747,839      35
Sept 36	   459,682      36
Sept 37	   609,567      36
Sept 38	   979,475      36
Sept 39	   837,189      36"
DF <- read.table(textConnection(sampDat), header = TRUE)
attach(DF)
@
\begin{verbatim}
Using Hmisc.....
\end{verbatim}
<<tab.R,echo=FALSE,results=tex>>=
library(Hmisc)
mytab <- data.frame(DF)
latex(DF,label="tab:hola",longtable=FALSE,caption='Sample table.')
@
\begin{verbatim}
Or with xtable....
\end{verbatim}
<<tab.RR,echo=F,results=tex>>=
library(xtable)
table2 <- data.frame(DF)
table2 <- xtable(DF,label='tab2',caption='table 2 with xtable',digits=0)
print(table2,floating=FALSE)
@
\end{document}

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA




More information about the R-help mailing list