Blame | Last modification | View Log | Download | RSS feed
\documentclass[a4paper]{article}\title{Using objects as chunk options}\author{Vincent Goulet and R Core Team}\begin{document}\maketitleThe following code chunk checks if a package \textbf{foo} isavailable on the system, and defines two dimensions.<<>>=hasfoo <- requireNamespace("foo", quietly = TRUE)ht <- 5wd <- (1 + sqrt(5))/2 * ht@Sweave will evaluate the following code chunk only if the packageis available (which should normally not be the case).<<eval=hasfoo>>=foo::foo(42)@We may also redo the boxplot of the \texttt{airquality} datasetin proportions approximately equal to the golden ratio.\begin{center}<<echo=FALSE, fig=TRUE, width=wd, height=ht>>=data(airquality, package="datasets")library("graphics")boxplot(Ozone ~ Month, data = airquality)@\end{center}\end{document}