I'm using the Hmisc
package in R to generate a reproducible LaTex table and would like to suppress some of the horizontal lines (\midrule
) generated by default in the booktabs mode. I've sifted through the Hmisc documentation as well as a number of Hmisc solutions here and on tex.stackexchange and I don't believe anything like this has been answered yet (but please correct me if I'm wrong).
Here's a minimal example that should be reproducible:
library(Hmisc)
myDF <- data.frame("foo" = c(1:10),
"bar" = rep(c("a","b"),5),
"baz" = c(21:30))
latex(myDF,
file="",
rowname = "",
rowlabel = "",
rgroup = c("Group A", "Group B", "Group C"),
n.rgroup = c(3, 4, 3),
booktabs = TRUE
)
Which generates the following output:
%latex.default(myDF, file = "", rowname = "", rowlabel = "", rgroup = c("Group A", "Group B", "Group C"), n.rgroup = c(3, 4, 3), booktabs = TRUE, )%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{lrlr}
\toprule
\multicolumn{1}{l}{}&\multicolumn{1}{c}{foo}&\multicolumn{1}{c}{bar}&\multicolumn{1}{c}{baz}\tabularnewline
\midrule
{\bfseries Group A}&&&\tabularnewline
~~&$ 1$&a&$21$\tabularnewline
~~&$ 2$&b&$22$\tabularnewline
~~&$ 3$&a&$23$\tabularnewline
\midrule
{\bfseries Group B}&&&\tabularnewline
~~&$ 4$&b&$24$\tabularnewline
~~&$ 5$&a&$25$\tabularnewline
~~&$ 6$&b&$26$\tabularnewline
~~&$ 7$&a&$27$\tabularnewline
\midrule
{\bfseries Group C}&&&\tabularnewline
~~&$ 8$&b&$28$\tabularnewline
~~&$ 9$&a&$29$\tabularnewline
~~&$10$&b&$30$\tabularnewline
\bottomrule
\end{tabular}\end{center}
\end{table}
How can I suppress some or all occurrences of '\midrule' in the output?
Please note that while I'm not attached to solving this with Hmisc
, I have some constraints that the rgroup
flag solves in a very effective way. While I do not believe that xtable
or stargazer
(for example) provide usable alternatives, I'm certainly open to other packages as long as I can preserve a layout with row groupings as provided in my example.