我在RStudio中遇到了kableExtra输出的一些问题。我点击“编织”后尝试在R降价文件中创建格式化表格。按钮。
代码是:
kable(temp_table, "html") %>%
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 2, "Group 3" = 2)) %>%
kable_styling(bootstrap_options = c("striped", "condensed", "hover", "responsive"), font_size = 11, full_width = FALSE, position = "left") %>%
column_spec(1, bold = T)
它应该创建一个带有我添加的标题行的简单表。但这不仅不会出现,而且变量行名称也不会出现。表格前面的是一堆看起来没有渲染的HTML代码。
某些版本历史记录:
kableExtra - 0.6.1
knitr - 1.17
rmarkdown - 1.7
R - 3.3.3
RStudio - 1.1.258
感谢任何帮助!
----更新----
下面是一个简单的可重复示例,它给出了相同类型的输出。
---
title: "Iris Example"
output_file: "iris2.html"
---
## Iris Data
``` {r iris, echo = FALSE, warning = FALSE}
library(data.table)
library(knitr)
library(kableExtra)
iris <- data.table(iris)
iris <- iris[, .(
sep_len = mean(Sepal.Length)
, sep_wid = mean(Sepal.Width)
, pet_len = mean(Petal.Length)
, pet_wid = mean(Petal.Width)
), by = .(Species)]
kable(iris, "html") %>%
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 2)) %>%
kable_styling(bootstrap_options = c("striped", "condensed", "hover", "responsive"), font_size = 10, full_width = FALSE, position = "left") %>%
column_spec(1, bold = T)
```
答案 0 :(得分:0)
我只在OS X上重现了这个输出。 使用安装最新版本的kableExtra(0.7.0.9000) devtools :: install_github(“haozhu233 / kableExtra”)为我解决了这个问题。