I am producing an automatic report using Sweave in R. I would like:
- In position (nrow -1) I would like to have a toprule instead of a midrule
- Align the first row as being centered and then I would like to align number to the right in order to align digits.
Here is my code:
\documentclass[a4paper,18pt]{article}
\usepackage[top=2.5cm, left=2.5cm, right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{Sweave}
\usepackage{booktabs}
\makeatletter
\def\hrulefill#1{\leavevmode\leaders\hrule\@height#1\hfill \kern\z@}
\makeatother
\begin{document}
\SweaveOpts{concordance=TRUE}
<<xtable1, results=tex,echo=FALSE>>=
library(xtable)
> data
l w a m
x NA 515.0 0.22 127.83
y NA 75.0 0.45 33.75
z NA 85.0 0.45 38.25
xtab <- xtable(data)
hline <- c(-1,0,nrow(xtab)-1,nrow(xtab))
align(xtab) <- "lcccc"
print(xtab,booktabs=T,hline.after=hline)
@
\end{document}