我正在根据分析创建Rmarkdown文档。我正在实现kableExtra包来格式化我的表。即使滚动,我也希望将行标题固定在顶部。如何保持标题固定在顶部?
从小插图“使用knitr :: kable和kableExtra创建Awesome HTML表”中,我看到它显示为“从版本1.1.0开始,如果您有固定高度的框,则标题行是固定的。”我检查过我是否拥有最新版本,但情况似乎并非如此。我也尝试了命令fixed_thead,但没有成功。
library(dplyr)
library(kableExtra)
why <- c(1,2,3,4,5,6,7,8,9,10)
wont <- c(1,2,3,4,5,6,7,8,9,10)
these <- c(1,2,3,4,5,6,7,8,9,10)
headers <- c(1,2,3,4,5,6,7,8,9,10)
stay <- c(1,2,3,4,5,6,7,8,9,10)
fixed <- c(1,2,3,4,5,6,7,8,9,10)
table_data <- data.frame(why, wont, these, headers, stay, fixed)
table_data %>%
kable( format = "html") %>%
kable_styling(position = "center", full_width = F, bootstrap_options = c("striped","hover"))%>%
scroll_box( width = "1000px", height = "200px", fixed_thead = T)