【问题标题】:Rendering differences with character vectors in Rmarkdown notebooks between RStudio and rmarkdown::render()RStudio 和 rmarkdown::render() 之间 Rmarkdown 笔记本中字符向量的渲染差异
【发布时间】:2021-06-13 04:10:52
【问题描述】:

我遇到了让我困惑的事情,我觉得我一定错过了一些明显的事情。

当我通过简单地将向量的名称(例如abc)放在一个块中来在 Rmarkdown 笔记本中打印字符向量时,这会在 RStudio 中按预期呈现。但是当我使用rmarkdown::render() 渲染笔记本时,它会打印两次。一次如预期:

[1] "a" "b" "c"

还有一次有很多额外的空间:

a
    
b
    
c

使用print(abc) 可以解决问题并打印相同的任何一种方式,但我宁愿不必这样做...

此外,使用output_format = "html_document" 进行渲染可以按预期进行。我只看到html_notebook 输出。

这似乎不会影响数字向量或因子,只会影响字符向量。

带有测试笔记本的要点在这里:https://gist.github.com/jashapiro/20ad401c9834638e4dee699e44ab7167

我是否应该向rmarkdown::render() 添加一个参数以使其表现得像 RStudio 一样?

我尝试了--vanillaxfun::Rscript_call(),但得到了相同的结果。

我已经使用 rmarkdown 2.6 和 2.7 R 4.03 和 4.04 对此进行了测试。我觉得也许我在早期版本中没有这个问题,但我不能肯定。

【问题讨论】:

    标签: r r-markdown rstudio


    【解决方案1】:

    我显然遇到了一个已知的错误;已经存在很长时间的一个:https://github.com/rstudio/rmarkdown/issues/1568

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-06
      • 2018-02-15
      • 1970-01-01
      • 2013-10-17
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 2019-12-30
      相关资源
      最近更新 更多