使用r Markdown,kable和kableExtra渲染表时出现问题 [英] Problems rendering table using r Markdown, kable and kableExtra
问题描述
我正在尝试使用r markdown,kable和kableExtra输出乳胶表.在表格呈现代码中出现错误,该错误不属于R生成的乳胶代码.
I am attempting to output a latex table using r markdown, kable and kableExtra. I get an error in the table rendering code that is not part of the latex code produced by R.
代码:
outTab <- m.OutTab %>%
kable(format='latex', booktabs=T ,
#caption = "Population Trend",
digits=1,
row.names=FALSE,
align='lccccc',
col.names = names_spaced,
escape = FALSE)
其中"m.OutTab"是一个包含要呈现的表的矩阵,
where "m.OutTab" is an matrix that contains the table to be rendered,
错误:
Error producing PDF.
! Misplaced \noalign.
\addlinespace ->\noalign
{\ifnum 0=`}\fi \@ifnextchar [{\@addspace }{\@addsp...
l.116 \addlinespace
Error: pandoc document conversion failed with error 43
这些代码("\ noalign ...")不属于"outTab".
These codes ("\noalign ...") is not part of "outTab".
有什么办法解决此错误吗?
Any idea how to work around this error?
推荐答案
如果您使用书本,则可能是由于在代码块标签中使用非字母数字字符引起的.我有一个类似的问题,可以通过删除下划线来解决.
If you are using bookdown, this could be caused by using non-alphanumeric characters in your code chunk label. I had a similar problem which was solved by removing an underscore.
这篇关于使用r Markdown,kable和kableExtra渲染表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!