Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用kable()生成跨越多个页面的表_R_Rstudio_R Markdown - Fatal编程技术网

R 使用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()生成一个跨越多个页面的表。我知道使用xtable()和“longtable”选项可以实现这一点,但我需要kable()来实现其他功能

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。。。缺少闭合支架。