Search code examples
rlatexsweave

R Sweave "not run" option


I use Sweave in R to make a package vignette and would like to know if there is a way to "not run" certain code within a Sweave tag, for example:

\documentclass{article}
\usepackage{Sweave}

\begin{document}

<<a>>=
source("http://bioconductor.org/biocLite.R")
biocLite("Rgraphviz",depend=TRUE)
@

<<<b>>=
x <- 1
cat(x, "\n")
@ 

\end{document}

Is there an option in Sweave to not run the code in the <<a>>= tag? (I could simply use "verbatim" instead of a Sweave tag, but is there something like a "not run" as for Rd files?) I looked into the options in the Sweave User Manual, but did not find what I am looking for.


Solution

  • You can use the eval option on your code chunk. Something like :

    <<a, eval=FALSE, echo=TRUE>>=
    source("http://bioconductor.org/biocLite.R")
    biocLite("Rgraphviz",depend=TRUE)
    @