【问题标题】:How to incorporate html table in Rmarkdown如何在 Rmarkdown 中合并 html 表格
【发布时间】:2015-03-26 06:05:26
【问题描述】:

我使用包“sjPlot”来运行一些数据分析。瞬间,函数 'sjt.df' 给了我一个关于变量简单描述的 html 表格。然后我创建了一个 Rmarkdown(见下文)。但是当我点击 knit HTML/pdf 时,html 表的结果并没有合并到 Rmarkdown 中。相反,它在我的浏览器中弹出。我该如何处理?

 {r}
library(sjPlot)
data(iris)
sjt.df(iris)

【问题讨论】:

    标签: html r r-markdown


    【解决方案1】:

    请参阅我的教程basics of sjt-functionsHTML 表格的 Knitr 集成部分

    如果您只想拥有表格,请使用'r sjt.df(iris, no.output=TRUE)$knitr' - (注意 ' 必须是 `)。

    no.output=TRUE 确保表格不会显示在查看器窗格或浏览器中,$knitr 参数包含将合并到 RMarkdown 中的 HTML-sn-p。

    如果您还想显示 R 代码,请使用

    ```{r eval=FALSE}
    sjt.df(iris)
    ```
    

    但是,我猜这些表格不能很好地转换为 PDF,只能转换为 HTML。

    【讨论】: