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

☆樱花仙子☆ 提交于 2019-12-25 04:57:15

问题


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.

来源:https://stackoverflow.com/questions/42568024/create-pdf-format-table-that-can-wrap-the-text-well-in-rmarkdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!