4

I'd like to document some R functions (not scripts) as html pages using spin(). 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. Is there a way to prevent the actual execution of all chunks with on single command at the beginning?

loki
  • 9,816
  • 7
  • 56
  • 82
user2955884
  • 405
  • 2
  • 11

1 Answers1

4

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
}
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • 1
    Thanks. Should I put knitr::opts_chunk$set(eval = TRUE) at the end so that the option does not affect subsequent scripts? – user2955884 Sep 08 '14 at 07:33
  • @user2955884 Yes, although normally this is not a problem if you compile your documents in separate R sessions, like what RStudio does. – Yihui Xie Sep 08 '14 at 21:29