gpt4 book ai didi

r - 注释的连续行在 knitr 中使用 R 3 拆分,但不是 R 2.15.3

转载 作者:行者123 更新时间:2023-12-04 09:08:09 25 4
gpt4 key购买 nike

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

非常感谢!!!

最佳答案

这应该是 fixedknitr v1.4.12现在,它将最终在 CRAN 上变成 knitr v1.5。

关于r - 注释的连续行在 knitr 中使用 R 3 拆分,但不是 R 2.15.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18992260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com