我有一个R脚本,可以从编织给定.Rmd文件的python管道中调用。但是,代码块的输出行为在R版本之间会发生变化,我想要旧的行为!
这是我用来编织.Rmd文件的脚本:
#!/project/csbio/Scott/Software/R-x.xx.x/bin/Rscript
library(knitr)
library(formatR)
# Create filename
rmdFile <- paste(cmds[2], '.Rmd', sep = '')
# Set knitr, formatR options
render_jekyll(highlight = 'prettify')
options('tidy.opts' = list(width.cutoff = 60))
options('width' = 80)
# Knit to jekyll-compatible markdown
knit(input = rmdFile)
这是我的示例.Rmd文件:
```{r comment-1}
# Here is a comment...I want this comment to wrap onto the next line without a space inserted between them, but I have no idea what is causing this behavior, so I ask the kind strangers on stack overflow.
```
使用R-2.15.3进行编织的结果:
<pre><code class="prettyprint "># Here is a comment...I want this comment to wrap onto the next line
# without a space inserted between them, but I have no idea what is
# causing this behavior, so I ask the kind strangers on stack overflow.
</code></pre>
以及使用R-3.0.1进行编织的结果:
<pre><code class="prettyprint "># Here is a comment...I want this comment to wrap onto the next line without</code></pre>
<pre><code class="prettyprint "># a space inserted between them, but I have no idea what is causing this</code></pre>
<pre><code class="prettyprint "># behavior, so I ask the kind strangers on stack overflow.</code></pre>
结果是在R 3.0.1中,注释行在每次换行时都被空格分隔。
我的问题是:什么原因导致R版本之间的这种行为,我该如何解决?
非常感谢!!!
最佳答案
现在应该是fixed中的knitr v1.4.12,最终将在CRAN上变成knitr v1.5。