Die*_*nne 5 r pandoc knitr r-markdown pander
下面的文档给出了以下HTML输出(仅需要HTML)

第一列是宽的,使用pandoc.table()减少表的单元格宽度和字体大小对此没有帮助.
如何强制前两列浪费更少的空间?
---
output: html_document
---
```{r,echo=FALSE, results="asis"}
library(pander)
mytab = data.frame(col1=1:2, col2=2001:2002, col3="This is a lengthy test that should wrap, and wrap again, and again and again and again")
pandoc.table(mytab)
```
Run Code Online (Sandbox Code Playgroud)
dar*_*zig 11
pandoc.table支持通过参数指定列的宽度split.cells,可以采用简单的数字或(相对)数字/百分比的向量,快速演示:
> pandoc.table(mytab, split.cells = c(1,1,58))
----------------------------------------------------------------------
col1 col2 col3
------ ------ --------------------------------------------------------
1 2001 This is a lengthy test that should wrap, and wrap again,
and again and again and again
2 2002 This is a lengthy test that should wrap, and wrap again,
and again and again and again
----------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
在将上述降价转换为HTML后,会产生以下HTML pandoc:
<table>
<col width="9%" />
<col width="9%" />
<col width="77%" />
<thead>
<tr class="header">
<th align="center">col1</th>
<th align="center">col2</th>
<th align="center">col3</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2001</td>
<td align="center">This is a lengthy test that should wrap, and wrap again, and again and again and again</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2002</td>
<td align="center">This is a lengthy test that should wrap, and wrap again, and again and again and again</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4734 次 |
| 最近记录: |