]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/sweave.lyx
UserGuide.lyx: fix some typographic issues spotted by Mike
[lyx.git] / lib / examples / sweave.lyx
index af215de3b5508393604daf3bf9d9f8a50a03810b..bf770bed8ca2a3ae31f7646eb4f38e17baa5b54a 100644 (file)
@@ -1,7 +1,9 @@
-#LyX 2.1 created this file. For more info see http://www.lyx.org/
-\lyxformat 474
+#LyX 2.2 created this file. For more info see http://www.lyx.org/
+\lyxformat 508
 \begin_document
 \begin_header
+\save_transient_properties true
+\origin /systemlyxdir/examples/
 \textclass article
 \begin_preamble
 %% maxwidth is the original width if it's less than linewidth
@@ -24,16 +26,16 @@ sweave
 \language_package auto
 \inputencoding default
 \fontencoding global
-\font_roman palatino
-\font_sans lmss
-\font_typewriter lmtt
-\font_math auto
+\font_roman "palatino" "default"
+\font_sans "lmss" "default"
+\font_typewriter "lmtt" "default"
+\font_math "auto" "auto"
 \font_default_family default
 \use_non_tex_fonts false
 \font_sc false
 \font_osf false
-\font_sf_scale 100
-\font_tt_scale 100
+\font_sf_scale 100 100
+\font_tt_scale 100 100
 \graphics default
 \default_output_format default
 \output_sync 0
@@ -130,7 +132,8 @@ maxwidth}
 \end_layout
 
 \begin_layout Title
-Using Sweave with LyX
+Using Sweave with \SpecialChar LyX
+
 \end_layout
 
 \begin_layout Author
@@ -196,13 +199,16 @@ http://www.r-project.org
 \end_inset
 
 ) for dynamic report generation using the ideas of literate programming.
- R code can be mixed into a LaTeX document, and will be executed in R when
- the document is compiled; the results are written into the TeX output.
+ R code can be mixed into a \SpecialChar LaTeX
+ document, and will be executed in R when the
+ document is compiled; the results are written into the \SpecialChar TeX
+ output.
 \end_layout
 
 \begin_layout Standard
-Since LyX 2.0, Sweave can be used out of the box with any document class
- using the 
+Since \SpecialChar LyX
+ 2.0, Sweave can be used out of the box with any document class using
+ the 
 \family sans
 Sweave
 \family default
@@ -211,10 +217,11 @@ Sweave
 \family sans
 Sweave
 \family default
- module to a LyX document from 
+ module to a \SpecialChar LyX
+ document from 
 \family sans
-Document\SpecialChar \menuseparator
-Settings\SpecialChar \menuseparator
+Document\SpecialChar menuseparator
+Settings\SpecialChar menuseparator
 Modules
 \family default
 .
@@ -278,9 +285,9 @@ PATH
 \family default
  anyway), or go to 
 \family sans
-Tools\SpecialChar \menuseparator
-Preferences\SpecialChar \menuseparator
-Paths\SpecialChar \menuseparator
+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 
@@ -323,9 +330,10 @@ R.home('bin')
 \end_layout
 
 \begin_layout Standard
-After you have done these changes, you need to reconfigure LyX by 
+After you have done these changes, you need to reconfigure \SpecialChar LyX
+ by 
 \family sans
-Tools\SpecialChar \menuseparator
+Tools\SpecialChar menuseparator
 Reconfigure
 \family default
 .
@@ -344,7 +352,8 @@ Sweave
  module will be unavailable.
  It is recommended to use the latest version of R, since Sweave is still
  being updated.
- Another dependency is introduced by the LaTeX style file 
+ Another dependency is introduced by the \SpecialChar LaTeX
+ style file 
 \family sans
 Sweave.sty
 \family default
@@ -376,8 +385,11 @@ file.path(R.home('share'), 'texmf', 'tex', 'latex')
 \end_layout
 
 \begin_layout Standard
-MikTeX users may add the texmf directory to the list of root directories
- in MikTeX through MikTeX settings.
+Mik\SpecialChar TeX
+ users may add the texmf directory to the list of root directories in
+ Mik\SpecialChar TeX
+ through Mik\SpecialChar TeX
+ settings.
  Further note that 
 \family sans
 Sweave.sty
@@ -395,7 +407,8 @@ may
 ae
 \series default
 .
- If LyX cannot find 
+ If \SpecialChar LyX
+ cannot find 
 \family sans
 Sweave.sty
 \family default
@@ -415,16 +428,19 @@ Before we write an Sweave document, we can set some Sweave options; the
 \backslash
 SweaveOpts{}
 \family default
- in Sweave and it can be inserted in a LyX document by 
+ in Sweave and it can be inserted in a \SpecialChar LyX
+ document by 
 \family sans
-Insert\SpecialChar \menuseparator
-Custom Insets\SpecialChar \menuseparator
+Insert\SpecialChar menuseparator
+Custom Insets\SpecialChar menuseparator
 Sweave Options
 \family default
-, or just use TeX code to write it (
+, or just use \SpecialChar TeX
+ code to write it (
 \family sans
-Insert\SpecialChar \menuseparator
-TeX Code
+Insert\SpecialChar menuseparator
+\SpecialChar TeX
+ Code
 \family default
 ).
  For example, we can set a global option 
@@ -432,18 +448,21 @@ TeX Code
 echo=FALSE
 \family default
  in the beginning of a document to suppress all R code (by default, both
- R code and its output will show up in the LaTeX document).
+ R code and its output will show up in the \SpecialChar LaTeX
+ document).
  
 \end_layout
 
 \begin_layout Standard
-To write R code in LyX, you can first switch to the 
+To write R code in \SpecialChar LyX
+, you can first switch to the 
 \family typewriter
 Chunk
 \family default
  environment in the layout styles list (droplist in the top-left corner
- in the toolbar), or you can simply open a TeX code environment and write
- Sweave code chunks in it.
+ in the toolbar), or you can simply open a \SpecialChar TeX
+ code environment and write Sweave
+ code chunks in it.
  The latter approach is recommended since it is more stable.
 \end_layout
 
@@ -649,13 +668,15 @@ Note that we can easily integrate some numbers into standard text; this
 \backslash
 Sexpr{}
 \family default
-, and the corresponding LyX menu is 
+, and the corresponding \SpecialChar LyX
+ menu is 
 \family sans
-Insert\SpecialChar \menuseparator
-Custom Insets\SpecialChar \menuseparator
+Insert\SpecialChar menuseparator
+Custom Insets\SpecialChar menuseparator
 S/R expression
 \family default
-, or alternatively just use TeX code.
+, or alternatively just use \SpecialChar TeX
+ code.
  For example, the third element of the vector 
 \family typewriter
 x
@@ -858,8 +879,9 @@ xtable
 \family typewriter
 results=tex
 \family default
- makes sure that the R output is written out as raw LaTeX code instead of
- being wrapped in a special environment (
+ makes sure that the R output is written out as raw \SpecialChar LaTeX
+ code instead of being
+ wrapped in a special environment (
 \family typewriter
 Soutput
 \family default
@@ -1018,8 +1040,8 @@ name "fig:iris-boxplots"
 We can also export all the R code in an Sweave document as a single R script
  (
 \family sans
-File\SpecialChar \menuseparator
-Export\SpecialChar \menuseparator
+File\SpecialChar menuseparator
+Export\SpecialChar menuseparator
 R/S code
 \family default
 ), which is done via 
@@ -1042,9 +1064,11 @@ The
 \family sans
 Sweave
 \family default
- module declares that a LyX document contains literate programming components
- with R, so that LyX will handle such documents according to the specific
- converters (see the Customization manual).
+ module declares that a \SpecialChar LyX
+ document contains literate programming components
+ with R, so that \SpecialChar LyX
+ will handle such documents according to the specific converter
+s (see the Customization manual).
  The 
 \family sans
 Sweave
@@ -1061,13 +1085,17 @@ lyxsweave.R
 \family sans
 scripts
 \family default
- directory of LyX.
+ directory of \SpecialChar LyX
+.
  This script takes an 
 \family sans
 Rnw
 \family default
- document from LyX and call Sweave to process it to a TeX document, then
- LyX takes care of the rest of work.
+ document from \SpecialChar LyX
+ and call Sweave to process it to a \SpecialChar TeX
+ document, then \SpecialChar LyX
+ takes
+ care of the rest of work.
 \end_layout
 
 \begin_layout Standard
@@ -1075,7 +1103,8 @@ The converter from the
 \family sans
 sweave
 \family default
- format to LaTeX is a call to R via the command line as:
+ format to \SpecialChar LaTeX
+ is a call to R via the command line as:
 \end_layout
 
 \begin_layout Standard
@@ -1108,18 +1137,21 @@ end{verbatim}
 \end_layout
 
 \begin_layout Standard
-The LyX library directory 
+The \SpecialChar LyX
+ library directory 
 \family typewriter
 $$s
 \family default
  can be found from the menu 
 \family sans
-Help\SpecialChar \menuseparator
-About LyX
+Help\SpecialChar menuseparator
+About \SpecialChar LyX
+
 \family default
 .
  All the rest of options passed to R are explained in the R script, and
- the LyX Customization manual also has detailed explanations about 
+ the \SpecialChar LyX
+ Customization manual also has detailed explanations about 
 \family typewriter
 $$i
 \family default
@@ -1141,8 +1173,9 @@ $$r
 \end_layout
 
 \begin_layout Enumerate
-the encoding string of the LyX document is passed to R as an command line
- option; possible values are 
+the encoding string of the \SpecialChar LyX
+ document is passed to R as an command line option;
+ possible values are 
 \family typewriter
 ISO-8859-15
 \family default
@@ -1160,7 +1193,8 @@ Rnw
 
 \begin_layout Enumerate
 the R code chunks in the Sweave document are executed under the directory
- of the LyX document (if you are not sure, put 
+ of the \SpecialChar LyX
+ document (if you are not sure, put 
 \family typewriter
 getwd()
 \family default
@@ -1171,12 +1205,14 @@ getwd()
 \end_layout
 
 \begin_layout Enumerate
-if LaTeX cannot find 
+if \SpecialChar LaTeX
+ cannot find 
 \family sans
 Sweave.sty
 \family default
 , this R script will copy it to the temporary directory automatically where
- the LaTeX compilation takes place.
+ the \SpecialChar LaTeX
+ compilation takes place.
 \end_layout
 
 \begin_layout Enumerate
@@ -1189,8 +1225,9 @@ target "http://www.lyx.org/trac/ticket/7551"
 
 \end_inset
 
-) is that if the filename (without extension) contains dots, LaTeX can fail
- to deal with such files in 
+) is that if the filename (without extension) contains dots, \SpecialChar LaTeX
+ can fail to
+ deal with such files in 
 \family typewriter
 
 \backslash
@@ -1263,7 +1300,8 @@ end{verbatim}
 \end_layout
 
 \begin_layout Standard
-LyX can deal with the font encoding by default, so there is no need to ask
+\SpecialChar LyX
+ can deal with the font encoding by default, so there is no need to ask
  Sweave to do this (furthermore, this may bring clashes of package options);
  besides, the users can load the 
 \series bold
@@ -1277,14 +1315,14 @@ Trouble Shooting
 \end_layout
 
 \begin_layout Standard
-Since LyX 2.0, we can see the detailed information during compilation via
+Since \SpecialChar LyX
+ 2.0, we can see the detailed information during compilation via 
 \family sans
-View\SpecialChar \menuseparator
+View\SpecialChar menuseparator
 View Messages
 \family default
 .
- This is extremely helpful for trouble shooting -- the process of R will
+ This is extremely helpful for trouble shooting  the process of R will
  be shown in the message panel, and we will be able to know which chunk
  goes wrong in cases of errors.
  For example, when you compile this document, you can see messages like
@@ -1371,11 +1409,13 @@ label=
 
 \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 
+ alignment of the chunk paragraph in \SpecialChar LyX
+ (using 
 \family sans
 Paragraph settings
 \family default
-), because LyX may add a macro like 
+), because \SpecialChar LyX
+ may add a macro like 
 \family typewriter
 
 \backslash
@@ -1423,7 +1463,7 @@ This is not a legitimate Sweave code chunk, since
  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\SpecialChar menuseparator
 View Source
 \family default
  when changing the alignment of a chunk paragraph, and make sure 
@@ -1480,7 +1520,9 @@ http://cran.r-project.org/web/views/ReproducibleResearch.html
 \end_inset
 
 .
- Questions about LyX and Sweave can be posted to the LyX mailing list (
+ Questions about \SpecialChar LyX
+ and Sweave can be posted to the \SpecialChar LyX
+ mailing list (
 \begin_inset Flex URL
 status collapsed
 
@@ -1492,7 +1534,8 @@ http://www.lyx.org/MailingLists
 \end_inset
 
 ).
- More LyX examples are provided at 
+ More \SpecialChar LyX
+ examples are provided at 
 \begin_inset Flex URL
 status collapsed
 
@@ -1515,8 +1558,10 @@ How to use Sweave with beamer?
 \end_layout
 
 \begin_layout Standard
-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.
+You will end up with \SpecialChar LaTeX
+ errors if you use Sweave in normal beamer slides in
+ \SpecialChar LyX
+; the reason is the beamer frame that contains verbatim R code.
  The solution is to use a 
 \emph on
 FragileFrame
@@ -1531,7 +1576,7 @@ fragile
 \family default
  to the frame title via 
 \family sans
-Insert\SpecialChar \menuseparator
+Insert\SpecialChar menuseparator
 Frame Options
 \family default
 .
@@ -1569,11 +1614,13 @@ user directory
 \emph default
  (again, see 
 \family sans
-Help\SpecialChar \menuseparator
-About LyX
+Help\SpecialChar menuseparator
+About \SpecialChar LyX
+
 \family default
 ).
- Note LyX will check the 
+ Note \SpecialChar LyX
+ will check the 
 \emph on
 user directory
 \emph default
@@ -1586,9 +1633,11 @@ library directory
 lyxsweave.R
 \family default
  is found in the user directory, it will be used.
- It is not recommended to hack the script under the LyX library directory
- directly, since updating LyX will override you modified script (the user
- directory will not be affected).
+ It is not recommended to hack the script under the \SpecialChar LyX
+ library directory directly,
+ since updating \SpecialChar LyX
+ will override you modified script (the user directory will
+ not be affected).
 \end_layout
 
 \begin_layout Standard