简体   繁体   English

knitr :: spin防止所有块被执行

[英]knitr::spin Prevent all chunks for being executed

I'd like to document some R functions (not scripts) as html pages using spin(). 我想使用spin()将一些R函数(不是脚本)记录为html页面。 I thought of something like: 我想到了类似的东西:

#' Test of rmarkdown  wit spin() for an html documented function
#' =======================================================
#+ eval=FALSE
test <- function(x,y)
{
  #' comment 1
  z <- x + y 
  #' comment 2
  z
}

But the #+ eval=FALSE applies to the first chunk only. #+ eval=FALSE仅适用于第一个块。 Is there a way to prevent the actual execution of all chunks with on single command at the beginning? 有没有办法在开始时使用单个命令阻止所有块的实际执行?

Set it globally: 全局设置:

#' Test of rmarkdown  wit spin() for an html documented function
#' =======================================================
#+ setup, include=FALSE
knitr::opts_chunk$set(eval = FALSE)
#+
test <- function(x,y) {
  # comment 1
  z <- x + y
  # comment 2
  z
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM