html kable_styling 没有在 for 循环中显示输出 [英] html kable_styling not showing output in a for loop
本文介绍了html kable_styling 没有在 for 循环中显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 for 循环中使用 kable 在 HTML rmarkdown 中生成大量表格.我一直在寻找解决方案,其中大部分都是使用围绕 kable 代码的包装器打印解决的.但是当我想用 kable_styling 生成 html 表输出时,这个解决方案不起作用!例如:
I want to use kable inside a for loop to generate a lot of tables in a HTML rmarkdown. I was looking for solutions and most of them are solved using the wrapper print around kable code. But when I want to generate html table outputs with kable_styling, this solution didn't work! For example:
table <- tibble(a = c(1:10),
b = letters[1:10])
for(each in 1:2) {
print(table %>%
kable())
cat("<br>")
}
这会生成两个简单的表.
This generate two simple tables.
但是当我尝试时:
table <- tibble(a = c(1:10),
b = letters[1:10])
for(each in 1:2) {
print(table %>%
kable() %>%
kable_styling("striped"))
cat("<br>")
}
什么都没发生!这仅适用于 html 输出.用乳胶就好了.我该怎么办?
Nothing happens! And that's only for html outputs. With latex it's ok. What should I do?
推荐答案
将 htmltools::HTML()
添加到您的管道:
Add htmltools::HTML()
to your pipe:
table %>%
kable() %>%
kable_styling("striped") %>%
htmltools::HTML() %>%
print
这篇关于html kable_styling 没有在 for 循环中显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文