knitr,R Markdown和HTML表格中的xtable:xtable表 [英] knitr, R Markdown, and xtable: xtable tables within HTML table

查看:1483
本文介绍了knitr,R Markdown和HTML表格中的xtable:xtable表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想用xtable并排打印HTML表格。我试图用.Rmd文件做这件事:

Suppose I want to print HTML tables using xtable, side-by-side. I tried doing this in an .Rmd file with:

<table border = 1>
<tr>
<td>
`r functionThatPrintsAnHTMLTableUsingxtable`
</td>
<td>
`r functionThatPrintsAnotherHTMLTableUsingxtable`
</td>
</tr>
</table>

没有骰子。我究竟做错了什么?感谢。

No dice. What am I doing wrong? Thanks.

推荐答案

我认为如果你把 results = asis

I think your code will work if you put results=asis in the chunk options.

<table border = 1>
<tr>
<td>
```{r results='asis', echo=FALSE}
  library(xtable)
  data(tli)
  print(xtable(tli[1:20, ]),type='html')
```
</td>
<td>
```{r results='asis', echo=FALSE}
  library(xtable)
  data(tli)
  print(xtable(tli[1:20, ]),type='html',comment=FALSE)
```
</td>
</tr>
</table>

这篇关于knitr,R Markdown和HTML表格中的xtable:xtable表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆