用于在recommendation文档中注释以使用HTML注释<!-- comment here -->的.Rmd是不够的。我想评论一下我的文档中包含内联评估的一个部分:
I haven't defined `x` yet.
<!-- So when I say that `x` is `r x` in the text, I'd like to comment it out -->编织失败:
# |.................................................................| 100%
# inline R code fragments
#
#
#
#
# processing file: test.Rmd
# Quitting from lines 2-3 (test.Rmd)
# Error in eval(expr, envir, enclos) : object 'x' not found
# Calls: <Anonymous> ... in_dir -> inline_exec -> withVisible -> eval -> eval
# Execution halted一种选择是对每个内联部分进行注释:
I haven't defined `x` yet.
So when I say that `x` is `r #x` in the text, I'd like to comment it out但是,如果我想用几个这样的内联计算来注释整个段落,就会受到影响,例如。有没有更规范的方法来做这件事?
发布于 2017-05-05 12:00:47
正如@NicE所说,knitr首先评估您的代码,特别是因为可能有内联R代码计算或其他R变量相关文本,然后需要作为标记语法进行计算。例如,这包括在rmarkdown中:
Define if bold `r bold <- TRUE`
This text is `r ifelse(bold, "**bold**", "_italic_")`.给予:
定义是否粗体 这段文字是粗体。
然后,我认为在不计算注释的情况下插入注释的唯一方法是将它们嵌入到eval=FALSE & echo=FALSE块中。
```{r, eval=FALSE, echo=FALSE}所以当我在文本中说x是r x时,我想把它注释掉
发布于 2017-10-20 20:36:29
我发现yaml区块的评论要好得多
---
title: "Untitled"
author: "baptiste"
date: "10/21/2017"
output: html_document
---
I haven't defined `x` yet.
---
# here's a comment
# ```{r}
# x = pi
# ```
---不幸的是,它似乎不适用于前面分析过的内联r代码。
https://stackoverflow.com/questions/43784515
复制相似问题