Tables in pander, style = "multiline"

I am using RStudio 0.98.1056 for Windows 7, and whatever the current version of pander on CRAN is today (I just installed the package).

I am trying to use the workflow knitr-> Markdown β†’. docx to create a table in Word. Some of the cells must contain hard line breaks. I believe that this should be possible based on the information in the following link:

http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html

It says: "A backslash followed by a new line is also a hard line break. Note: in multi-line grid cells and a grid, this is the only way to create a hard line break, since trailing spaces in cells are ignored."

I am trying to create a table with cells containing line breaks as follows:

library(pander) a <- c(1:10) b <- c(11:20) ab <- paste(a,b,sep='\n') N <- ceiling(rpois(10,9)) labels <- paste("Question",c(1:10)) mytable <- data.frame(labels,ab,N) pandoc.table(mytable, style="multiline") 

But the new line is just stripped. Same thing if I use sep = "<newline>" or sep = "<br>" (without leading spaces). I also tried adding an extra backslash in case R β€œate” the first; and the inclusion of an insert function to include each of these possible delimiters as its own term, rather than in the sep = argument. None of these things worked.

I tried the sample code in the pander reference documentation, just like a health check, and it seems that the problem in general is the sample code, which I thought should create multi-row tables on my machine.

Has anyone else got multi-row tables in pander to work?

+6
source share
1 answer

Yup, please install the development version from GitHub - this issue was fixed several months ago . For instance:.

 > panderOptions('keep.line.breaks', TRUE) > pander(mytable) -------------------- labels ab N ----------- ---- --- Question 1 1 11 11 Question 2 2 6 12 Question 3 3 13 13 Question 4 4 12 14 Question 5 5 6 15 Question 6 6 6 16 Question 7 7 11 17 Question 8 8 19 18 Question 9 9 10 19 Question 10 10 9 20 -------------------- 
+7
source

Source: https://habr.com/ru/post/975329/


All Articles