相关疑难解决方法(0)

Markdown中的评论

将注释存储在markdown文件中的语法是什么,例如文件顶部的CVS $ Id $注释?降价项目我什么都没发现.

syntax markdown comments

1277
推荐指数
17
解决办法
41万
查看次数

注释掉部分Rmd文件

是否可以注释掉包含多个块(例如:4-5)的Rmd文件的一部分?常规HTML注释无效。

---
title: "Untitled"
author: "author"
date: "5 August 2017"
output: pdf_document
---

```{r}
print(123)
```

```{r}
2**2
```
<!-- 
# Comment section starts

This text is not visible in the output.

```{r}
a <- 3*4
a
```
This text not be visible in the output.

# Comment section ends
-->

```{r}
print(1)
```
Run Code Online (Sandbox Code Playgroud)

过去,我记得在SO帖子的某处读到它的目标是下一版knitr

更新:我并不是要eval=FALSE在每个块中使用该解决方案,因为我也需要注释掉块之间的文本。另外,我正在寻找一种优雅的方式来做到这一点。

上面的代码输出pdf输出,如下所示:

在此处输入图片说明

令人惊讶的是,它有效。但是相同的HTML注释(<!-- -->)在另一个原始Rmarkdown脚本中不起作用。仅在包含以下要跳过执行的代码的代码段之后,才实现跳过Rmd文件的一部分。

<!-- 
# Comment section starts

```{r, include=FALSE}
knitr::opts_chunk$set(eval= FALSE)
```

This …
Run Code Online (Sandbox Code Playgroud)

r rstudio knitr r-markdown

6
推荐指数
1
解决办法
3396
查看次数

评论rmarkdown/knitr以防止R评估

建议在注释.Rmd文档中使用HTML注释<!-- comment here -->是不够的.我想评论一下我的文档中包含内联评估的部分:

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 -->
Run Code Online (Sandbox Code Playgroud)

编织失败:

#   |.................................................................| 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 …
Run Code Online (Sandbox Code Playgroud)

r knitr r-markdown

4
推荐指数
1
解决办法
516
查看次数

标签 统计

knitr ×2

r ×2

r-markdown ×2

comments ×1

markdown ×1

rstudio ×1

syntax ×1