【发布时间】:2015-04-03 12:22:48
【问题描述】:
我一直在使用 xtable 包从 R 矩阵中创建 HTML 表格。当我在循环中使用函数kable 时,它没有输出任何东西。所以我盯着使用print 函数,该函数有效。问题是当我使用打印功能时,我会沿着表格 HTML 打印很多“##”。有没有办法打印我的 kable,但在循环中避免每行出现“##”?
library("xtable", lib.loc="~/R/win-library/3.1")
for(i in 1:3) {
#Must use print because of the loop, but get ## per line
print(kable(head(cars), "html", table.attr='class="flat-table"'))
}
#No neded to use print, no ## printed per line
kable(head(cars), "html", table.attr='class="flat-table"')
【问题讨论】:
-
您没有将 kable 或 print 的输出分配给任何东西。