0

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.

Community
  • 1
  • 1
Bin
  • 517
  • 1
  • 4
  • 15
  • The `split.cells` argument can help only if the cells contains strings that can be split, eg an English sentence with spaces -- and the split will happen on space characters. You can also try the `use.hyphening = TRUE` arg so that `split.cells` would even split words based on hyphenation rules, but if you have such gibberish text in the cells, you will have to preprocess the `data.frame` before calling `pander`. – daroczig Mar 04 '17 at 00:29
  • Hi daroczig, I have no idea how to preprocess the data.frame in this case, so that the display when calling pander function will be wrapped. Can you give some hints or references? – Bin Mar 04 '17 at 00:33

0 Answers0