4

我有一个 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 版本之间的这种行为,我该如何解决?

非常感谢!!!

4

1 回答 1

3

这应该现在在knitr v1.4.12中修复,最终将在 CRAN 上变成 knitr v1.5。

于 2013-09-24T22:25:44.207 回答