I'm using RStudio 0.98.1056 on Windows 7, and whatever the current version of pander is on CRAN as of today (I just installed the package).
I'm trying to use the knitr->Markdown->.docx literate-programming workflow to create a table in Word. Some of the cells need to contain hard line breaks. I believe this should be possible based on info in the following link:
http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html
It says, "A backslash followed by a newline is also a hard line break. Note: in multiline and grid table cells, this is the only way to create a hard line break, since trailing spaces in the cells are ignored."
I'm trying to create a table with cells containing line breaks in the following way:
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 newline just gets stripped. Same if I use sep="< newline>" or sep="< br>" (without leading spaces). I have also tried adding an extra backslash, in case R was "eating" the first one; and switching up the "paste" function to include each of these possible separators as a term in their own right, instead of in the sep= argument. None of these things worked.
I went to try out the example code in the pander help documentation, just as a sanity check, and it seems the issue is general -- sample code that I thought should produce multiline tables did not, on my machine.
Has anyone else gotten multiline tables in pander to work?
pander(mytable)
I get the same output you saw in R. On the other hand, that output doesn't knit properly to either HTML or docx: the linebreaks are removed. What am I missing? I'm still usingpandoc.table(mytable, style="multiline")
instead of the simpler syntax, so that's not the issue. I've also tried with style="grid": no dice. – Febrile