#LyX 2.0.0beta4 created this file. For more info see http://www.lyx.org/ \lyxformat 412 \begin_document \begin_header \textclass article \use_default_options true \begin_modules pgfsweave \end_modules \maintain_unincluded_children false \language english \language_package default \inputencoding auto \fontencoding global \font_roman default \font_sans default \font_typewriter default \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 \bibtex_command default \index_command default \paperfontsize default \spacing single \use_hyperref false \papersize default \use_geometry false \use_amsmath 1 \use_esint 1 \use_mhchem 1 \use_mathdots 1 \cite_engine basic \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \use_refstyle 1 \index Index \shortcut idx \color #008000 \end_index \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \html_math_output 0 \html_be_strict false \end_header \begin_body \begin_layout Title pgfSweave under LyX 2.0 (beta) \end_layout \begin_layout Date Yihui Xie \end_layout \begin_layout Standard Since LyX 2.0, you will be able to use Sweave with \emph on any \emph default document classes, because it is now a \emph on module \emph default instead of a \emph on layout \emph default . A module can be inserted in any LyX documents by \family sans Document \family default \SpecialChar \menuseparator \family sans Settings \family default \SpecialChar \menuseparator \family sans Modules \family default \SpecialChar \menuseparator \family sans pgfSweave \family default . Note the environment for Sweave has been renamed to \family sans Chunk \family default , but the former name \family sans Scrap \family default is compatible, so you do not need to worry about anything if you have been using LyX 1.6.x. \end_layout \begin_layout Standard Here comes a few toy examples: \end_layout \begin_layout Chunk <>= \end_layout \begin_layout Chunk rnorm(5)+runif(5) \end_layout \begin_layout Chunk @ \end_layout \begin_layout Standard There will not be blank lines between R code lines, so you can turn off the Sweave option \family typewriter tidy \family default and turn on \family typewriter keep.source \family default to preserve your own formatting: \end_layout \begin_layout Chunk <>= \end_layout \begin_layout Chunk legend("bottomright" \end_layout \begin_layout Chunk ,legend = sprintf("$ \backslash \backslash hat{Y} = %.2f + %.2fx$" \end_layout \begin_layout Chunk ,coef(model)[1] \end_layout \begin_layout Chunk ,coef(model)[2]) \end_layout \begin_layout Chunk ,bty = "n" \end_layout \begin_layout Chunk ) \end_layout \begin_layout Chunk @ \end_layout \begin_layout Standard Lazy guys can leave the job of formatting R code to the \family typewriter tidy \family default option: \end_layout \begin_layout Chunk <>= \end_layout \begin_layout Chunk legend("bottomright" \end_layout \begin_layout Chunk ,legend = sprintf("$ \backslash \backslash hat{Y} = %.2f + %.2fx$" \end_layout \begin_layout Chunk ,coef(model)[1] \end_layout \begin_layout Chunk ,coef(model)[2]) \end_layout \begin_layout Chunk ,bty = "n" \end_layout \begin_layout Chunk ) \end_layout \begin_layout Chunk @ \end_layout \end_body \end_document