Create pdf-format table that can wrap the text well in rmarkdown

时间:2017-03-02 23:37:41

标签: pdf r-markdown pandoc pander

pdf file scratch

I used the rmarkdown to create a pdf file, where some tables are included in the output. The tables are created by using pander function.

As you see, the output does not wrap the text well, so the output is quite dirty.

Suppose the code is as follows:

 title: "Untitled"
 output: pdf_document
 ---


 ```{r kable}
 library(xtable)

 a <- rep(1,5)
 b <- rep("33333333333333333333333333333333333333333333333333333333333333333", 5)
 c <- rep("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", 5)
 data <- as.data.frame( cbind(a, b, c) )
 ```


 ```{r b}
 library(pander)
 pander(data, split.cells = 5, split.table = Inf)

 ```

 ```{r c}
 pander(data, split.cells = 5)

 ```

I do not know if there is any method to create pdf-format table that can wrap the text well.

I have tried the method in this link. wrap long text in kable table column But it fails.

0 个答案:

没有答案
相关问题