R描述和R Markdown

标签 r r-markdown xtable

我想在 R Markdown 文件中描述我的数据表,使用

xtable(data, type='html')

但到目前为止,我查看的所有软件包似乎都与 html 设置中的 xtable 兼容,f.i. Hmisc::describe,reporttools::tableNominal.

有人对此有解决方案吗?

示例: 就像是 Variables Overview with xtable in R 但在 Markdown/html 中工作。

最佳答案

试试 pander 包。特别是该包中的 pandoc.table 函数

> pandoc.table(head(mtcars), split.tables=Inf, style='rmarkdown')


|                    |  mpg  |  cyl  |  disp  |  hp  |  drat  |  wt   |  qsec  |  vs  |  am  |  gear  |  carb  |
|:-----------------------:|:-----:|:-----:|:------:|:----:|:------:|:-----:|:------:|:----:|:----:|:------:|:------:|
|      **Mazda RX4**      |  21   |   6   |  160   | 110  |  3.9   | 2.62  | 16.46  |  0   |  1   |   4    |   4    |
|    **Mazda RX4 Wag**    |  21   |   6   |  160   | 110  |  3.9   | 2.875 | 17.02  |  0   |  1   |   4    |   4    |
|     **Datsun 710**      | 22.8  |   4   |  108   |  93  |  3.85  | 2.32  | 18.61  |  1   |  1   |   4    |   1    |
|   **Hornet 4 Drive**    | 21.4  |   6   |  258   | 110  |  3.08  | 3.215 | 19.44  |  1   |  0   |   3    |   1    |
|  **Hornet Sportabout**  | 18.7  |   8   |  360   | 175  |  3.15  | 3.44  | 17.02  |  0   |  0   |   3    |   2    |
|       **Valiant**       | 18.1  |   6   |  225   | 105  |  2.76  | 3.46  | 20.22  |  1   |  0   |   3    |   1    |

该 Markdown 表应呈现如下

enter image description here

关于R描述和R Markdown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19493119/

相关文章:

r - 带有多行标题的print.xtable?

r - rmarkdown 中的传单热图

r - xtable 只剩下

r - 带有切割 y 轴的分组条形图

r - 更改shinyWidgets pickerInput的样式

r - 由 rmarkdown 生成的 pdf 文档中表格的标题

r - 内联代码和内联 LaTeX、R Markdown Pandoc 错误 43

r - 使用 xtable 生成带有重要星号 (***) 的 Latex 表

r - 如何用 ggplot 绘制过零的离散填充轮廓?

r - 如何交换R中命名向量的名称和值?