使用 R markdown 编写 Word .doc 时将 table 标题放在顶部

Put table captions on top when knitting Word .doc with R markdown

Table 在 RStudio 中使用 R markdown 编写 Word 文档时,标题位于 table 下方。我需要 table 上方的 table 字幕。

我已经尝试了 kable() 和 pander() 函数但没有成功。

编织 .pdf 时使用 xtable() 的解决方案可以在这里找到: How to make RMarkdown (.Rmd) table captions go at the top

但是,据我所知 xtable() 在编织到 Word .doc 时不兼容。

由于底部 table 标题的 pandoc 政策,此选项的功能在 How to position and format length of a table's title [R Markdown, pander package] 中被低估了。我最近访问 pandoc 文档表明该政策已被废除。

我想继续使用 R markdown 编写 Word 文档,但如果 table 标题仍然低于 table,我将不得不放弃。

根据 daroczig 的评论,我能够通过在 R 中使用以下命令安装最新版本的 pandoc 来找到解决方案:

library(installr)
install.pandoc()

请注意,重新安装最新版本的 RStudio 不会更新 pandoc。此解决方案适用于 R 3.2.2; install.pandoc() 在 R 3.1.3 中出现错误,手动安装 pandoc(即从 R 外部使用 msi 文件)没有解决问题。