R 使用kable()生成跨越多个页面的表
我想使用kable()生成一个跨越多个页面的表。我知道使用xtable()和“longtable”选项可以实现这一点,但我需要kable()来实现其他功能R 使用kable()生成跨越多个页面的表,r,rstudio,r-markdown,R,Rstudio,R Markdown,我想使用kable()生成一个跨越多个页面的表。我知道使用xtable()和“longtable”选项可以实现这一点,但我需要kable()来实现其他功能 kable(output, "latex", booktabs = TRUE, longtable = TRUE, caption = "Test") %>% kable_styling(latex_options = c("hold_position", "repeat_header")) 有什么想法吗 ```{r cars,
kable(output, "latex", booktabs = TRUE, longtable = TRUE, caption = "Test") %>%
kable_styling(latex_options = c("hold_position", "repeat_header"))
有什么想法吗
```{r cars, echo=TRUE, results='asis', warning=FALSE, message=FALSE}
library(knitr)
library(kableExtra)
# OUTPUT 1, fits on one page
output = rbind(mtcars[, 1:5])
kable(output, booktabs = T, format="latex", caption = "Small Output")
# OUTPUT 2, will not fit on one page
output = rbind(mtcars[, 1:5], mtcars[, 1:5])
kable(output, booktabs = T, format="latex", caption = "Large Output")
```
kable(output, "latex", booktabs = TRUE, longtable = TRUE, caption = "Test") %>%
kable_styling(latex_options = c("hold_position", "repeat_header"))
更新:我很笨!“longtable=TRUE”是一个选项。问题是,这改变了我输出的顺序,并有点搞砸了 您可以尝试使用kableExtra软件包。如果在
kable\u样式设置
中指定hold\u position
,则应该能够将表格ping到所需的位置
kable(output, "latex", booktabs = TRUE, longtable = TRUE, caption = "Test") %>%
kable_styling(latex_options = c("hold_position", "repeat_header"))
另外,在当前的开发版本中,我为longtable
引入了一个名为repeat\u header
的新特性,在每页上重复页眉行。你可以去看看
kable(output, "latex", booktabs = TRUE, longtable = TRUE, caption = "Test") %>%
kable_styling(latex_options = c("hold_position", "repeat_header"))
你可以在这里找到完整的套装小插曲我刚刚认出了你的id。。。缺少闭合支架。