摆脱kable中的\ addlinespace

时间:2017-07-31 07:25:55

标签: r latex knitr sweave

在knitr / Sweave报告中,kable knitr函数booktabs=TRUE选项\addlinespace每第五行添加一个P1 & A & 10 & 11.016181 & 110.16181 & 44.95101 & 269.9745\\ P1 & B & 10 & 8.592386 & 85.92386 & 35.06083 & 210.5743\\ P1 & A & 100 & 120.610305 & 120.61031 & 58.61274 & 248.1857\\ P1 & B & 100 & 94.990728 & 94.99073 & 46.16245 & 195.4671\\ P2 & A & 1000 & 698.097191 & 69.80972 & 37.34843 & 130.4846\\ \addlinespace P2 & B & 1000 & 837.649249 & 83.76492 & 44.81452 & 156.5690\\ P2 & A & 10000 & 10356.365176 & 103.56365 & 49.47422 & 216.7883\\ P2 & B & 10000 & 10214.989594 & 102.14990 & 48.79884 & 213.8289\\ \bottomrule

\addlinespace

是否可以在使用booktabs=TRUE选项的情况下摆脱这些{{1}}?

1 个答案:

答案 0 :(得分:30)

您可以将参数linesep = ""添加到kable。这将被传递到kable_latex,覆盖默认的

linesep = if (booktabs) c('', '', '', '', '\\addlinespace') else '\\hline'

示例:

kable(cars, format = "latex", booktabs = TRUE, linesep = "")