相关疑难解决方法(0)

使用kable()生成跨越多个页面的表

我想使用kable()生成一个跨越多个页面的表.我知道这可以使用带有"longtable"选项的xtable(),但是我需要kable()来实现其他功能.

有任何想法吗?

```{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")

```
Run Code Online (Sandbox Code Playgroud)

更新:我很蠢!"longtable = TRUE"是一种选择.问题是,这改变了我的输出顺序,有点混乱.

r rstudio r-markdown

7
推荐指数
1
解决办法
4089
查看次数

如何控制 rmarkdown / knit 文件的输出顺序(或如何防止浮动)

我遇到的问题类似于“ R,knitr 不尊重块和文本的顺序”中提出的问题。在我的代码中,我有一个文本标题,后跟一个块,该块使用四个 knit::kable 函数调用来显示四个表。奇怪的是,在 PDF 输出中,表 1 和表 2 出现在标题上方,表 3 和表 4 出现在下方。看来这与针织物允许物体漂浮有关。我可以最好在 knitr::kable 函数或块选项中关闭它吗?这是我的代码:

---
title: "Reproducible Error"
author: "Rex Macey"
date: "February 14, 2017"
output: pdf_document
header-includes: 
- \usepackage{placeins}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

\newpage  

# Section 1  
```{r CompTables, echo=FALSE, warning=FALSE, results='asis', out.extra='FloatBarrier'}
comptables1<-matrix(rep(c(100,200,300,400,500),3),nrow=5,ncol=3)
colnames(comptables1)<-c("Conservative","Moderate","Aggressive")
row.names(comptables1)<-c("5th %-tile","25th %-tile","50th %-tile","75th %-tile","95th %-tile")
comptables2<-matrix(0,nrow=6,ncol=3)
comptables2[1,]<-comptables1[1,]
for (i in 2:5){
    comptables2[i,]<-comptables1[i,]-comptables1[i-1,]
}
comptables<-list()
comptables[[1]]<-list(comptables1,comptables2)
comptables[[2]]<-list(comptables1,comptables2)
comptables[[3]]<-list(comptables1,comptables2)
comptables[[4]]<-list(comptables1,comptables2)

knitr::kable(comptables[[1]][1],
         caption="Table of Forecast Wealth Values: Suggested …
Run Code Online (Sandbox Code Playgroud)

r knitr r-markdown

5
推荐指数
1
解决办法
8783
查看次数

标签 统计

r ×2

r-markdown ×2

knitr ×1

rstudio ×1