2016-11-10 148 views
0

这是我的例子:如何在Rmarkdown中旋转或调整大表格?

--- 
title: "There is a reproductible example" 
output: pdf_document 
--- 

```{r table-simple, echo=FALSE, message=FALSE, warnings=FALSE, results='asis'} 
require(pander) 
panderOptions('table.split.table', Inf) 
set.caption("My great data") 
my.data <- " # replace the text below with your table data 
Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement 
Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement 
Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement 
Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement|Anticonstitutionnellement " 

df <- read.delim(textConnection(my.data),header=FALSE,sep="|",strip.white=TRUE,stringsAsFactors=FALSE) 
names(df) <- unname(as.list(df[1,])) # put headers on 
df <- df[-1,] # remove first row 
row.names(df)<-NULL 
pander(df, style = 'rmarkdown') 
``` 

在最后的PDF输出,词重叠。

我使用“kable”,“table”,“print”
您是否有一个想法,这些词不重叠?

如果表格非常庞大,我希望表格以横向格式自动旋转。可能吗?

回答

0

您可以尝试添加选项:

classoption: landscape 

在你的脑袋节

--- 
title: "There is a reproductible example" 
output: pdf_document 
classoption: landscape 
--- 

这将产生文档的风景版本。