]> git.lyx.org Git - lyx.git/commitdiff
an example for the sweave module, prepared by Gregor Gorjanc
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 19 May 2009 14:01:30 +0000 (14:01 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 19 May 2009 14:01:30 +0000 (14:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29734 a592a061-630c-0410-9148-cb99ea01b6c8

development/scons/scons_manifest.py
lib/Makefile.am
lib/examples/sweave.lyx [new file with mode: 0644]

index 88c1792b693555d3b096d1918eef0d2bafaa6b81..bba4c29cdf65f9cb03de8e23aca96a8ffdb39add 100644 (file)
@@ -2429,6 +2429,7 @@ lib_examples_files = Split('''
     serial_letter3.lyx
     simplecv.lyx
     splash.lyx
+    sweave.lyx
     xyfigure.png
     xypic.lyx
 ''')
index b9c6b2bbdc3f4584434f67e67b49b39f4d75ee9b..bcaaa2b14aed790821a06f7e544bd3b33b3893ab 100644 (file)
@@ -246,6 +246,7 @@ dist_examples_DATA = \
        examples/serial_letter3.lyx \
        examples/simplecv.lyx \
        examples/splash.lyx \
+       examples/sweave.lyx \
        examples/xyfigure.png \
        examples/xypic.lyx
 
diff --git a/lib/examples/sweave.lyx b/lib/examples/sweave.lyx
new file mode 100644 (file)
index 0000000..3f08291
--- /dev/null
@@ -0,0 +1,361 @@
+#LyX 1.6.1 created this file. For more info see http://www.lyx.org/\r
+\lyxformat 345\r
+\begin_document\r
+\begin_header\r
+\textclass article\r
+\use_default_options true\r
+\begin_modules\r
+sweave\r
+\end_modules\r
+\language english\r
+\inputencoding auto\r
+\font_roman default\r
+\font_sans default\r
+\font_typewriter default\r
+\font_default_family default\r
+\font_sc false\r
+\font_osf false\r
+\font_sf_scale 100\r
+\font_tt_scale 100\r
+\r
+\graphics default\r
+\paperfontsize default\r
+\spacing single\r
+\use_hyperref false\r
+\papersize default\r
+\use_geometry false\r
+\use_amsmath 1\r
+\use_esint 1\r
+\cite_engine basic\r
+\use_bibtopic false\r
+\paperorientation portrait\r
+\secnumdepth 3\r
+\tocdepth 3\r
+\paragraph_separation skip\r
+\defskip medskip\r
+\quotes_language english\r
+\papercolumns 1\r
+\papersides 1\r
+\paperpagestyle default\r
+\tracking_changes false\r
+\output_changes false\r
+\author "" \r
+\author "" \r
+\end_header\r
+\r
+\begin_body\r
+\r
+\begin_layout Title\r
+A Test File\r
+\end_layout\r
+\r
+\begin_layout Author\r
+Friedrich Leisch\r
+\begin_inset Foot\r
+status collapsed\r
+\r
+\begin_layout Plain Layout\r
+LyX \r
+\begin_inset Quotes eld\r
+\end_inset\r
+\r
+port\r
+\begin_inset Quotes erd\r
+\end_inset\r
+\r
+ by Gregor Gorjanc\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+A simple example that will run in any S engine: The integers from 1 to 10\r
+ are\r
+\end_layout\r
+\r
+\begin_layout Chunk\r
+<<print=TRUE>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+1:10 \r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+<<results=hide>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+print(1:20)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@ % the above is just to ensure that 2 code chunks can follow each other\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+We can also emulate a simple calculator: \r
+\end_layout\r
+\r
+\begin_layout Chunk\r
+<<echo=TRUE,print=TRUE>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+1 + 1 \r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+1 + pi\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+sin(pi/2)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+Now we look at Gaussian data:\r
+\end_layout\r
+\r
+\begin_layout Chunk\r
+<<>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+library(stats)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+x <- rnorm(20)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+print(x)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+print(t1 <- t.test(x))\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+Note that we can easily integrate some numbers into standard text: The third\r
+ element of vector \r
+\family typewriter\r
+x\r
+\family default\r
+ is \r
+\begin_inset Flex S/R expression\r
+status collapsed\r
+\r
+\begin_layout Plain Layout\r
+\r
+x[3]\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+, the \r
+\begin_inset Formula $p$\r
+\end_inset\r
+\r
+-value of the test is \r
+\begin_inset Flex S/R expression\r
+status collapsed\r
+\r
+\begin_layout Plain Layout\r
+\r
+format.pval(t1$p.value)\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+\r
+\family roman\r
+\series medium\r
+\shape up\r
+\size normal\r
+\emph off\r
+\bar no\r
+\noun off\r
+\color none\r
+Now we look at a summary of the famous iris dataset, and we want to see\r
+ the commands in the code chunks:\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+\begin_inset Flex Sweave Options\r
+status open\r
+\r
+\begin_layout Plain Layout\r
+\r
+echo=true,keep.source=true\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\begin_layout Chunk\r
+<<engine=R>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+# A comment\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+data(iris)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+summary(iris)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@ % def\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+\begin_inset Float figure\r
+placement tbph\r
+wide false\r
+sideways false\r
+status collapsed\r
+\r
+\begin_layout Chunk\r
+\align center\r
+<<fig=TRUE>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+library(graphics)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+pairs(iris)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@\r
+\end_layout\r
+\r
+\begin_layout Plain Layout\r
+\begin_inset Caption\r
+\r
+\begin_layout Plain Layout\r
+Pairs plot of the iris data.\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+\begin_inset Float figure\r
+placement tbph\r
+wide false\r
+sideways false\r
+status collapsed\r
+\r
+\begin_layout Chunk\r
+\align center\r
+<<fig=true>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+boxplot(Sepal.Length~Species,data=iris)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@\r
+\end_layout\r
+\r
+\begin_layout Plain Layout\r
+\begin_inset Caption\r
+\r
+\begin_layout Plain Layout\r
+Boxplot of sepal length grouped by species.\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\begin_layout Chunk\r
+<<engine=S4>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+function.that.comes.only.with.Splus(x)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@\r
+\end_layout\r
+\r
+\begin_layout Standard\r
+\begin_inset Float figure\r
+wide false\r
+sideways false\r
+status open\r
+\r
+\begin_layout Chunk\r
+\align center\r
+<<fig=true>>=\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+boxplot(Sepal.Length~Species,data=iris)\r
+\begin_inset Newline newline\r
+\end_inset\r
+\r
+@\r
+\end_layout\r
+\r
+\begin_layout Plain Layout\r
+\begin_inset Caption\r
+\r
+\begin_layout Plain Layout\r
+Boxplot of sepal length grouped by species\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\end_inset\r
+\r
+\r
+\end_layout\r
+\r
+\end_body\r
+\end_document\r