#LyX 1.5.1 created this file. For more info see http://www.lyx.org/ \lyxformat 276 \begin_document \begin_header \textclass literate-article \language english \inputencoding auto \font_roman default \font_sans default \font_typewriter default \font_default_family default \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default \paperfontsize default \spacing single \papersize default \use_geometry false \use_amsmath 1 \use_esint 0 \cite_engine basic \use_bibtopic false \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \author "" \author "" \end_header \begin_body \begin_layout Standard An example of using Sweave with LyX. What follows is a chunk (scrap) of R code that will be evaluated during the compilation of the document. \end_layout \begin_layout Scrap <>= \newline xObs <- 100; xMean <- 10; xVar <- 9 \newline x <- rnorm(n=xObs, mean=xMean, sd=sqrt(xVar)) \newline mean(x) \newline @ \end_layout \begin_layout Standard We can insert an inline code chunks via \begin_inset Quotes eld \end_inset ERT \begin_inset Quotes erd \end_inset boxes. In the above chunk we have obtained \begin_inset ERT status open \begin_layout Standard \backslash Sexpr{xObs} \end_layout \end_inset draws from a normal distribution - \begin_inset Formula $N\left(\Sexpr{xMean},\Sexpr{xVar}\right)$ \end_inset . Finnaly, we can create a figure float with a code chunk. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Standard \backslash SweaveOpts{echo=FALSE} \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset Float figure placement tbph wide false sideways false status open \begin_layout Scrap \align center <>= \newline hist(x) \newline @ \end_layout \begin_layout Standard \begin_inset Caption \begin_layout Standard Histogram of \begin_inset ERT status open \begin_layout Standard \backslash Sexpr{xObs} \end_layout \end_inset draws from a normal distribution \end_layout \end_inset \end_layout \end_inset \end_layout \end_body \end_document