-#LyX 2.0 created this file. For more info see http://www.lyx.org/
-\lyxformat 413
+#LyX 2.1 created this file. For more info see http://www.lyx.org/
+\lyxformat 474
\begin_document
\begin_header
\textclass article
\font_roman palatino
\font_sans lmss
\font_typewriter lmtt
+\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
-
\graphics default
\default_output_format default
\output_sync 0
\use_hyperref false
\papersize default
\use_geometry true
-\use_amsmath 1
-\use_esint 1
-\use_mhchem 1
-\use_mathdots 1
+\use_package amsmath 1
+\use_package amssymb 1
+\use_package cancel 0
+\use_package esint 1
+\use_package mathdots 1
+\use_package mathtools 0
+\use_package mhchem 1
+\use_package stackrel 0
+\use_package stmaryrd 0
+\use_package undertilde 0
\cite_engine basic
+\cite_engine_type default
+\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
+\justification true
\use_refstyle 0
\index Index
\shortcut idx
\family sans
Sweave
\family default
- module, which means we no longer need to modify the
-\family sans
-preferences
-\family default
- file manually or add special layouts such as
-\family sans
-literate-article.layout
-\family default
- and
-\family sans
-literate-book.layout
-\family default
- like we did before.
+ module.
We can add the
\family sans
Sweave
\family sans
PATH
\family default
- under Windows, you may use the R script
+ under Windows, you may either use the R script
\family sans
add-R-path-win.R
\family default
\end_inset
- to change it automatically (we recommend you to learn
+ to change it automatically (not recommended; you should learn
\family sans
PATH
\family default
- anyway).
+ anyway), or go to
+\family sans
+Tools\SpecialChar \menuseparator
+Preferences\SpecialChar \menuseparator
+Paths\SpecialChar \menuseparator
+PATH prefix
+\family default
+ to add the bin path of R (recommended), which is often like
+\family sans
+C:
+\backslash
+Program Files
+\backslash
+R
+\backslash
+R-x.x.x
+\backslash
+bin
+\family default
+ and you can find it in R:
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
+<<where-is-R-bin,eval=FALSE>>=
+\end_layout
+
+\begin_layout Plain Layout
+
+R.home('bin')
+\end_layout
+
+\begin_layout Plain Layout
+
+@
+\end_layout
+
+\end_inset
+
+
\end_layout
\begin_layout Standard
-If
+After you have done these changes, you need to reconfigure LyX by
+\family sans
+Tools\SpecialChar \menuseparator
+Reconfigure
+\family default
+.
+ If
\family typewriter
Rscript
\family default
status open
\begin_layout Plain Layout
-\begin_inset Caption
+\begin_inset Caption Standard
\begin_layout Plain Layout
Quantiles of the first four variables in the
\end_layout
\begin_layout Plain Layout
+\align center
\begin_inset ERT
status open
\begin_layout Plain Layout
-
-\backslash
-begin{center}
\end_layout
\begin_layout Plain Layout
@
\end_layout
-\begin_layout Plain Layout
-
-
-\backslash
-end{center}
-\end_layout
-
\end_inset
status open
\begin_layout Plain Layout
-\begin_inset ERT
+\align center
+\begin_inset Note Note
status open
\begin_layout Plain Layout
+Both eps and pdf are set to true so that both latex and pdflatex work.
+ In practice, you would probably just choose one.
+\end_layout
+\end_inset
-\backslash
-begin{center}
-\end_layout
+
+\begin_inset ERT
+status open
\begin_layout Plain Layout
-<<iris-pairs,fig=TRUE,width=4.5,height=4.5>>=
+<<iris-pairs,fig=TRUE,width=4.5,height=4.5,eps=TRUE,pdf=TRUE>>=
\end_layout
\begin_layout Plain Layout
@
\end_layout
-\begin_layout Plain Layout
-
-
-\backslash
-end{center}
-\end_layout
-
\end_inset
\end_layout
\begin_layout Plain Layout
-\begin_inset Caption
+\begin_inset Caption Standard
\begin_layout Plain Layout
Scatter plot matrix of the
status open
\begin_layout Plain Layout
+\align center
\begin_inset ERT
status open
\begin_layout Plain Layout
-
-\backslash
-begin{center}
-\end_layout
-
-\begin_layout Plain Layout
-
-<<iris-boxplots,fig=TRUE,width=7,height=2,keep.source=F>>=
+<<iris-boxplots,fig=TRUE,width=7,height=2,keep.source=F,eps=T,pdf=T>>=
\end_layout
\begin_layout Plain Layout
@
\end_layout
-\begin_layout Plain Layout
-
-
-\backslash
-end{center}
-\end_layout
-
\end_inset
\end_layout
\begin_layout Plain Layout
-\begin_inset Caption
+\begin_inset Caption Standard
\begin_layout Plain Layout
Boxplots of sepal length grouped by species.
immediately.
\end_layout
+\begin_layout Standard
+Another known issue is the Sweave code chunk may fail when we change the
+ alignment of the chunk paragraph in LyX (using
+\family sans
+Paragraph settings
+\family default
+), because LyX may add a macro like
+\family typewriter
+
+\backslash
+centering{}
+\family default
+ before the code chunk without adding a new line, which will lead to a code
+ chunk like this:
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+begin{verbatim}
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+centering{}<<xtable-demo,results=tex,echo=FALSE>>=
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+end{verbatim}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+This is not a legitimate Sweave code chunk, since
+\family typewriter
+<<>>=
+\family default
+ must start in a new line with nothing before it.
+ Therefore we recommend you to double check the real source code via
+\family sans
+View\SpecialChar \menuseparator
+View Source
+\family default
+ when changing the alignment of a chunk paragraph, and make sure
+\family typewriter
+<<>>=
+\family default
+ appears in a new line.
+ This explains why we manually added an empty line in the code chunk in
+ Table
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "tab:xtable-demo"
+
+\end_inset
+
+.
+\end_layout
+
\begin_layout Section
Resources
\end_layout
\end_layout
\begin_layout Standard
-You will end up with LaTeX errors if you use Sweave in beamer slides in
- LyX; the reason is the beamer frame that contains verbatim R code and output
- must have the
+You will end up with LaTeX errors if you use Sweave in normal beamer slides
+ in LyX; the reason is the beamer frame that contains verbatim R code.
+ The solution is to use a
+\emph on
+FragileFrame
+\emph default
+ instead of a normal
+\emph on
+Frame
+\emph default
+, or to pass the option
\family typewriter
fragile
\family default
- option.
- However, currently there is no straightforward way to do this.
- One way is to write raw TeX code, and the other is to use the
-\family sans
-beamer-fragile.module
-\family default
- discussed in
-\begin_inset CommandInset href
-LatexCommand href
-name "#7273"
-target "http://www.lyx.org/trac/ticket/7273"
-
-\end_inset
-
- (put this file under the
-\family sans
-layouts
-\family default
- directory of LyX user directory and reconfigure LyX).
- After including this module in your document, you should be able to use
-
+ to the frame title via
\family sans
Insert\SpecialChar \menuseparator
-Custom Insets\SpecialChar \menuseparator
-FragileFrame
-\family default
-, which is essentially
-\family typewriter
-
-\backslash
-begin{frame}[fragile]
+Frame Options
\family default
.
\end_layout
\end_layout
\begin_layout Standard
-Beside the support for the official Sweave in R, we have a few customized
- R scripts to unofficially support other R packages under
-\begin_inset Flex URL
-status collapsed
-
-\begin_layout Plain Layout
-
-https://github.com/yihui/lyx
-\end_layout
-
-\end_inset
-
-, e.g., the
-\series bold
-pgfSweave
-\series default
- and the
+Beside the support for the official Sweave in R, the
\series bold
knitr
\series default
- package.
- The former supports cache and tikz graphics in R, and the latter is an
- alternative literate programming engine to Sweave which has even more features.
+ package is also supported, which is an alternative tool to Sweave; the
+ corresponding module is named
+\family sans
+Rnw (knitr)
+\family default
+.
\end_layout
\end_body