knitr 将降价文本视为逐字
knitr treats markdown text as verbatim
我正在尝试使用 R 中的 knitr
和 pander
包创建带有 table 的 pdf,但我的 [=39= 中的某些文本似乎] 被误解为代码,因为生成的文档在不应该的情况下将文本逐字显示。这是我能够复制问题的一些示例代码。
---
title: "Untitled"
author: "Me"
date: "10/07/2015"
output: pdf_document
classoption: landscape
---
\footnotesize
```{r,echo=F,message=F}
library(pander)
dat <- data.frame(test_name=c("Short","Really, really long test name","Other","The rest/Other/whatever"),
campaigns=c("AAA BBB CCC","AAA","BBB CCC","DDD"),
objective=c("We want to test whether or not the changes we made to our proceedure will change the outcome. We will test this from January 2015 to January 2016.","I am not very creative and cannot think of any other objectives especially since I made up the rest of this stuff.","Our objective is to improve the quality of our product.","The objective is to find out if people will like this other product better."),
results=c("The test we did resulted in the following results that were counter-intuitive since we expected other results.","None","This other test resulted in everything as we expected, blah, blah, blah.","None"))
myTable <- pander(dat,split.cells=c(20,10,60,60),split.table=Inf,style='grid',emphasize.strong.cols=c(1))
return(myTable)
```
我尝试使用 pander_return
而不是 pander
函数,然后使用 Pandoc.convert
将该文本转换为 LaTeX,这样我就可以替换所有 \begin{verbatim}
和 \end{verbatim}
什么都没有,但这没有用。现在这很有意义,因为我试图在我的 Rmd 文件中这样做。
就在发布这个问题之前,我确实注意到,如果我从 test_name
列中删除所有 /
,我就不再有该列的逐字问题,但是campaigns
和 results
列中仍然存在问题。
如何让它识别出文本是 markdown 而不是逐字代码?非常感谢任何帮助。
编辑:从第一列中删除 "special characters" 后,当它是单元格中的单个单词时,它似乎只将单元格文本视为逐字代码。否则它看起来不错。
根据@rawr 的评论,将 justify= 'left'
添加到 pander
函数解决了问题。
我正在尝试使用 R 中的 knitr
和 pander
包创建带有 table 的 pdf,但我的 [=39= 中的某些文本似乎] 被误解为代码,因为生成的文档在不应该的情况下将文本逐字显示。这是我能够复制问题的一些示例代码。
---
title: "Untitled"
author: "Me"
date: "10/07/2015"
output: pdf_document
classoption: landscape
---
\footnotesize
```{r,echo=F,message=F}
library(pander)
dat <- data.frame(test_name=c("Short","Really, really long test name","Other","The rest/Other/whatever"),
campaigns=c("AAA BBB CCC","AAA","BBB CCC","DDD"),
objective=c("We want to test whether or not the changes we made to our proceedure will change the outcome. We will test this from January 2015 to January 2016.","I am not very creative and cannot think of any other objectives especially since I made up the rest of this stuff.","Our objective is to improve the quality of our product.","The objective is to find out if people will like this other product better."),
results=c("The test we did resulted in the following results that were counter-intuitive since we expected other results.","None","This other test resulted in everything as we expected, blah, blah, blah.","None"))
myTable <- pander(dat,split.cells=c(20,10,60,60),split.table=Inf,style='grid',emphasize.strong.cols=c(1))
return(myTable)
```
我尝试使用 pander_return
而不是 pander
函数,然后使用 Pandoc.convert
将该文本转换为 LaTeX,这样我就可以替换所有 \begin{verbatim}
和 \end{verbatim}
什么都没有,但这没有用。现在这很有意义,因为我试图在我的 Rmd 文件中这样做。
就在发布这个问题之前,我确实注意到,如果我从 test_name
列中删除所有 /
,我就不再有该列的逐字问题,但是campaigns
和 results
列中仍然存在问题。
如何让它识别出文本是 markdown 而不是逐字代码?非常感谢任何帮助。
编辑:从第一列中删除 "special characters" 后,当它是单元格中的单个单词时,它似乎只将单元格文本视为逐字代码。否则它看起来不错。
根据@rawr 的评论,将 justify= 'left'
添加到 pander
函数解决了问题。