首先,我会告诉你我试图做什么,以便在我做错时进行更正。我有一个嵌套表格,想使用knitr在RStudio中输出为LaTeX表格。没有标题的情况下一切正常,但是添加标题后就不行了。我尝试了
理想情况下,我希望能在输出中使用
如果有帮助的话,这是输入和输出:
tables
文档((LINK)第9页)上的示例,但没有成功。对于非表格对象,它也能正常工作。有趣的是,latex.default
可以正常工作,但会导致RStudio/knitr的编译PDF出现错误,并且根据我的阅读,它被latex
调用;此外,表格的四舍五入也不适当了。我尝试了latexTabular
,但这也不适当地四舍五入。library(Hmisc); library(tables)
latex(head(mtcars), file="", caption="de") #works
x <- tabular( (Species + 1) ~ (n=1) + Format(digits=2)*
(Sepal.Length + Sepal.Width)*(mean + sd), data=iris )
latex(x, file="", caption="de") #no caption :(
理想情况下,我希望能在输出中使用
\caption{de}
,但我无法弄清楚我的错误在哪里。如果有帮助的话,这是输入和输出:
> latex(x, file="", caption="de", label="tab1")
\begin{tabular}{lccccc}
\hline
& & \multicolumn{2}{c}{Sepal.Length} & \multicolumn{2}{c}{Sepal.Width} \\
Species & n & mean & sd & mean & sd \\
\hline
setosa & $\phantom{0}50$ & $5.01$ & $0.35$ & $3.43$ & $0.38$ \\
versicolor & $\phantom{0}50$ & $5.94$ & $0.52$ & $2.77$ & $0.31$ \\
virginica & $\phantom{0}50$ & $6.59$ & $0.64$ & $2.97$ & $0.32$ \\
All & $150$ & $5.84$ & $0.83$ & $3.06$ & $0.44$ \\
\hline
\end{tabular}
tabular()
函数来自哪里? - Josh O'Brien