我正在使用带有外部代码选项的 knitr 包。有没有一种方法可以让我跳过一个块中的一行被读取?例如:
## @knitr chunk1
a <- 1:100
## This comment should not appear
## @knitr chunk2
print(a[1:12])
在上面的示例中,我希望第 3 行不会出现在最终的 *.pdf 中。非常感谢任何提示。
有两种方法可以做到这一点:
<<chunk1, echo=-2>>=
这意味着您要从输出中排除第二个表达式;## @knitr go-away
),或者根本没有标签 ( ## @knitr
)