Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use opts_chunk$set() to set global options; closes #216

  • Loading branch information...
commit 6395f0f62d5cf2b445554a04d8ac7570ee6dfd64 1 parent 82f6a04
@yihui authored
View
16 inst/examples/knitr-beamer.lyx
@@ -87,10 +87,18 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/beamer-',fig.align='center',fig.show='hold',size='footn
-otesize'}
+<<setup, include=FALSE>>=
+\end_layout
+
+\begin_layout Plain Layout
+
+opts_chunk$set(fig.path='figure/beamer-',fig.align='center',fig.show='hold',size='f
+ootnotesize')
+\end_layout
+
+\begin_layout Plain Layout
+
+@
\end_layout
\end_inset
View
30 inst/examples/knitr-graphics.lyx
@@ -88,30 +88,19 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/graphics-', cache.path='cache/graphics-', fig.align='ce
-nter', dev='tikz', fig.width=5, fig.height=5, fig.show='hold', cache=TRUE,
- par=TRUE}
-\end_layout
-
-\end_inset
-
-
+<<setup, include=FALSE, cache=FALSE>>=
\end_layout
-\begin_layout Standard
-\begin_inset ERT
-status open
-
\begin_layout Plain Layout
-<<setup, include=FALSE, cache=FALSE>>=
+options(replace.assign=TRUE,width=60)
\end_layout
\begin_layout Plain Layout
-options(replace.assign=TRUE,width=60)
+opts_chunk$set(fig.path='figure/graphics-', cache.path='cache/graphics-',
+ fig.align='center', dev='tikz', fig.width=5, fig.height=5, fig.show='hold',
+ cache=TRUE, par=TRUE)
\end_layout
\begin_layout Plain Layout
@@ -405,11 +394,11 @@ cairoDevice
\series default
package, e.g., the chunk below uses the
\emph on
-Cairo_png()
+CairoPNG()
\emph default
device in the
\series bold
-cairoDevice
+Cairo
\series default
package.
\end_layout
@@ -420,7 +409,7 @@ status open
\begin_layout Plain Layout
-<<cairo-png-dev, ref.label='test-plot', dev='Cairo_png', out.width='.5
+<<cairo-png-dev, ref.label='test-plot', dev='CairoPNG', out.width='.5
\backslash
\backslash
@@ -1771,7 +1760,8 @@ status open
\begin_layout Plain Layout
-<<ggobi-plot, custom.plot=TRUE, fig.ext='png', out.width='2.5in', results='hide'>>=
+<<ggobi-plot, custom.plot=TRUE, fig.ext='png', out.width='2.5in', results='hide',
+ warning=FALSE>>=
\end_layout
\begin_layout Plain Layout
View
4 inst/examples/knitr-latex.Rtex
@@ -2,7 +2,9 @@
\usepackage{graphicx}
%% for inline R code: if the inline code is not correctly parsed, you will see a message
\newcommand{\rinline}[1]{SOMETHING WRONG WITH knitr}
-%% roptions fig.path='figure/latex-', cache.path='cache/latex-'
+%% begin.rcode setup, include=FALSE
+% opts_chunk$set(fig.path='figure/latex-', cache.path='cache/latex-')
+%% end.rcode
\begin{document}
Boring stuff as usual:
View
10 inst/examples/knitr-listings.lyx
@@ -84,18 +84,12 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/listings-'}
-\end_layout
-
-\begin_layout Plain Layout
-
+<<setup, include=FALSE, cache=FALSE>>=
\end_layout
\begin_layout Plain Layout
-<<setup, include=FALSE, cache=FALSE>>=
+opts_chunk$set(fig.path = 'figure/listings-')
\end_layout
\begin_layout Plain Layout
View
26 inst/examples/knitr-manual.lyx
@@ -91,29 +91,30 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/manual-', cache.path='cache/manual-', fig.align='center
-', external=TRUE, fig.show='hold', par=TRUE}
+<<setup, include=FALSE, cache=FALSE>>=
\end_layout
-\end_inset
-
+\begin_layout Plain Layout
+## this is equivalent to
+\backslash
+SweaveOpts{}
\end_layout
-\begin_layout Standard
-\begin_inset ERT
-status open
+\begin_layout Plain Layout
+
+opts_chunk$set(fig.path='figure/manual-', cache.path='cache/manual-', fig.align='ce
+nter', fig.show='hold', par=TRUE)
+\end_layout
\begin_layout Plain Layout
-<<setup, include=FALSE, cache=FALSE>>=
+## I use = but I can replace it with <-; set code/output width to be 68
\end_layout
\begin_layout Plain Layout
-options(replace.assign=TRUE,width=90)
+options(replace.assign=TRUE, width=68)
\end_layout
\begin_layout Plain Layout
@@ -1390,8 +1391,7 @@ status open
\begin_layout Plain Layout
-<<fig-hold, fig=TRUE, fig.show='asis', dev='pdf', fig.width=6, fig.height=4,
- out.width='.35
+<<fig-hold, fig.show='asis', dev='pdf', fig.width=6, fig.height=4, out.width='.35
\backslash
\backslash
View
4 inst/examples/knitr-minimal.Rhtml
@@ -1,9 +1,11 @@
-<!--roptions fig.width=5, fig.height=5, fig.path='ex-out-' -->
<html>
<head>
<title>A minimal knitr example in HTML</title>
</head>
<body>
+<!--begin.rcode
+ opts_chunk$set(fig.width=5, fig.height=5, fig.path='ex-out-')
+ end.rcode-->
<p>This is a minimal example which shows <strong>knitr</strong>
working with HTML
View
16 inst/examples/knitr-minimal.lyx
@@ -83,23 +83,19 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/minimal-', fig.align='center', fig.show='hold'}
+<<setup, include=FALSE, cache=FALSE>>=
\end_layout
-\end_inset
-
+\begin_layout Plain Layout
+# this is equivalent to
+\backslash
+SweaveOpts{...}
\end_layout
-\begin_layout Standard
-\begin_inset ERT
-status open
-
\begin_layout Plain Layout
-<<setup, include=FALSE, cache=FALSE>>=
+opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold')
\end_layout
\begin_layout Plain Layout
View
14 inst/examples/knitr-subfloats.lyx
@@ -75,9 +75,17 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/subfloats-'}
+<<setup, include=FALSE>>=
+\end_layout
+
+\begin_layout Plain Layout
+
+opts_chunk$set(fig.path='figure/subfloats-')
+\end_layout
+
+\begin_layout Plain Layout
+
+@
\end_layout
\end_inset
View
10 inst/examples/knitr-themes.lyx
@@ -93,18 +93,12 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/theme-', cache.path='cache/theme-', cache=TRUE}
-\end_layout
-
-\begin_layout Plain Layout
-
+<<setup, include=FALSE, cache=FALSE>>=
\end_layout
\begin_layout Plain Layout
-<<setup, include=FALSE, cache=FALSE>>=
+opts_chunk$set(fig.path='figure/theme-', cache.path='cache/theme-', cache=TRUE)
\end_layout
\begin_layout Plain Layout
View
8 inst/examples/knitr-twocolumn.lyx
@@ -89,14 +89,12 @@ status open
\begin_layout Plain Layout
-%
-\backslash
-SweaveOpts{fig.path='figure/twocolumn-', fig.align='center', fig.show='hold'}
+<<setup, include=FALSE, cache=FALSE>>=
\end_layout
\begin_layout Plain Layout
-<<setup, include=FALSE, cache=FALSE>>=
+opts_chunk$set(fig.path='figure/twocolumn-', fig.align='center', fig.show='hold')
\end_layout
\begin_layout Plain Layout
@@ -151,7 +149,7 @@ status open
\begin_layout Plain Layout
-<<chunk-hook>>=
+<<chunk-hook, echo=2>>=
\end_layout
\begin_layout Plain Layout
View
4 inst/misc/knitr-minimal_knit_.html
@@ -1,5 +1,5 @@
-<!--roptions dev=png,fig.width=5,fig.height=5,fig.path=figure/html-template-,fig.align=center,par=TRUE -->
<!--begin.rcode setup,echo=FALSE,results=hide,message=FALSE,cache=FALSE
+ opts_chunk$set(fig.width=5,fig.height=5,fig.path='figure/html-template-',fig.align='center',par=TRUE)
options(replace.assign=TRUE, width=90)
knit_hooks$set(par=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1), cex.lab=.95, cex.axis=.9, mgp=c(2,.7,0), tcl=-.3, las=1)})
if (!exists('.knitr.title')) .knitr.title = 'A Report Generated by knitr'
@@ -12,7 +12,7 @@
<body>
<p>This report is automatically generated with the R
- package <a href="http://yihui.github.com/knitr"><strong>knitr</strong></a>
+ package <a href="http://yihui.name/knitr"><strong>knitr</strong></a>
(version <!--rinline packageVersion('knitr') -->)
by <!--rinline .knitr.author -->.</p>
View
5 inst/misc/knitr-template.Rnw
@@ -1,5 +1,3 @@
-%% LyX 2.1.0svn created this file. For more info, see http://www.lyx.org/.
-%% Do not edit unless you really know what you are doing.
\documentclass{article}
\usepackage[sc]{mathpazo}
\renewcommand{\sfdefault}{lmss}
@@ -28,9 +26,8 @@
\begin{document}
-% \SweaveOpts{fig.path=figure/latex-template-, fig.align=center, out.width=.6\linewidth, fig.width=6, fig.height=6, par=TRUE}
-
<<setup,echo=FALSE,results=hide,message=FALSE,cache=FALSE>>=
+opts_chunk$set(fig.path='figure/latex-template-', fig.align='center', out.width='.6\\linewidth', fig.width=6, fig.height=6, par=TRUE)
options(replace.assign=TRUE, width=90)
knit_hooks$set(par=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1), cex.lab=.95, cex.axis=.9, mgp=c(2,.7,0), tcl=-.3, las=1)})
if (!exists('.knitr.title')) .knitr.title = 'A Report Generated by knitr'
Please sign in to comment.
Something went wrong with that request. Please try again.