我正在使用R中knitr包中的stitch函数为我的学生创建R代码的html文件.
我有几百个R脚本,并且自动创建html页面的过程.
但是,如果我的R脚本包含注释行,例如
## ------示例------
然后是针脚功能thinks这是代码块的标签,并经常删除我脚本的其他部分.
有没有办法在函数turn off 中分块stitch()来传递所有代码as is?我已经查看了内部代码,stitch()并且read_chunk()似乎无法看到它## ----- Example -----是如何知道何时 是块标签.
这是最小的工作示例:R 3.0.1; knitr 1.4.1
# Test out problem with stitch in knitr
my.code <- "# This a sample of R code
x <- 1:10
print(x)
plot(x,x)
## ---------------- Example -----
# Notice that only this part of the code appears in the html file.
x <- 10:30
print(x)
plot(x,x)
NULL
"
writeLines(my.code, con='R.code') …Run Code Online (Sandbox Code Playgroud)