Debian Codegraph @

inst/examples/knitr-minimal.lyx

raw
1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 413
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \begin_modules
8 knitr
9 \end_modules
10 \maintain_unincluded_children false
11 \language english
12 \language_package none
13 \inputencoding default
14 \fontencoding global
15 \font_roman palatino
16 \font_sans default
17 \font_typewriter default
18 \font_default_family default
19 \use_non_tex_fonts false
20 \font_sc true
21 \font_osf false
22 \font_sf_scale 100
23 \font_tt_scale 100
24
25 \graphics default
26 \default_output_format default
27 \output_sync 0
28 \bibtex_command default
29 \index_command default
30 \paperfontsize default
31 \spacing single
32 \use_hyperref true
33 \pdf_bookmarks true
34 \pdf_bookmarksnumbered true
35 \pdf_bookmarksopen true
36 \pdf_bookmarksopenlevel 2
37 \pdf_breaklinks false
38 \pdf_pdfborder false
39 \pdf_colorlinks false
40 \pdf_backref false
41 \pdf_pdfusetitle true
42 \pdf_quoted_options "pdfstartview={XYZ null null 1}"
43 \papersize default
44 \use_geometry true
45 \use_amsmath 1
46 \use_esint 1
47 \use_mhchem 1
48 \use_mathdots 1
49 \cite_engine basic
50 \use_bibtopic false
51 \use_indices false
52 \paperorientation portrait
53 \suppress_date false
54 \use_refstyle 1
55 \index Index
56 \shortcut idx
57 \color #008000
58 \end_index
59 \leftmargin 2.5cm
60 \topmargin 2.5cm
61 \rightmargin 2.5cm
62 \bottommargin 2.5cm
63 \secnumdepth 2
64 \tocdepth 2
65 \paragraph_separation indent
66 \paragraph_indentation default
67 \quotes_language english
68 \papercolumns 1
69 \papersides 1
70 \paperpagestyle default
71 \tracking_changes false
72 \output_changes false
73 \html_math_output 0
74 \html_css_as_file 0
75 \html_be_strict false
76 \end_header
77
78 \begin_body
79
80 \begin_layout Standard
81 \begin_inset ERT
82 status open
83
84 \begin_layout Plain Layout
85
86 <<setup, include=FALSE, cache=FALSE>>=
87 \end_layout
88
89 \begin_layout Plain Layout
90
91 library(knitr)
92 \end_layout
93
94 \begin_layout Plain Layout
95
96 # set global chunk options
97 \end_layout
98
99 \begin_layout Plain Layout
100
101 opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold')
102 \end_layout
103
104 \begin_layout Plain Layout
105
106 options(formatR.arrow=TRUE,width=90)
107 \end_layout
108
109 \begin_layout Plain Layout
110
111 @
112 \end_layout
113
114 \end_inset
115
116
117 \end_layout
118
119 \begin_layout Title
120 A Minimal Demo of knitr
121 \end_layout
122
123 \begin_layout Author
124 Yihui Xie
125 \end_layout
126
127 \begin_layout Standard
128 You can test if
129 \series bold
130 knitr
131 \series default
132 works with this minimal demo.
133 OK, let's get started with some boring random numbers:
134 \end_layout
135
136 \begin_layout Standard
137 \begin_inset ERT
138 status open
139
140 \begin_layout Plain Layout
141
142 <<boring-random>>=
143 \end_layout
144
145 \begin_layout Plain Layout
146
147 set.seed(1121)
148 \end_layout
149
150 \begin_layout Plain Layout
151
152 (x=rnorm(20))
153 \end_layout
154
155 \begin_layout Plain Layout
156
157 mean(x);var(x)
158 \end_layout
159
160 \begin_layout Plain Layout
161
162 @
163 \end_layout
164
165 \end_inset
166
167
168 \end_layout
169
170 \begin_layout Standard
171 The first element of
172 \family typewriter
173 x
174 \family default
175 is
176 \begin_inset ERT
177 status collapsed
178
179 \begin_layout Plain Layout
180
181
182 \backslash
183 Sexpr{x[1]}
184 \end_layout
185
186 \end_inset
187
188 .
189 Boring boxplots and histograms recorded by the PDF device:
190 \end_layout
191
192 \begin_layout Standard
193 \begin_inset ERT
194 status open
195
196 \begin_layout Plain Layout
197
198 <<boring-plots, fig.width=4, fig.height=4, out.width='.4
199 \backslash
200
201 \backslash
202 linewidth'>>=
203 \end_layout
204
205 \begin_layout Plain Layout
206
207 ## two plots side by side (option fig.show='hold')
208 \end_layout
209
210 \begin_layout Plain Layout
211
212 par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3,las=1)
213 \end_layout
214
215 \begin_layout Plain Layout
216
217 boxplot(x)
218 \end_layout
219
220 \begin_layout Plain Layout
221
222 hist(x,main='')
223 \end_layout
224
225 \begin_layout Plain Layout
226
227 @
228 \end_layout
229
230 \end_inset
231
232
233 \end_layout
234
235 \begin_layout Standard
236 Do the above chunks work? You should be able to compile the TeX document
237 and get a PDF file like this one:
238 \begin_inset Flex URL
239 status collapsed
240
241 \begin_layout Plain Layout
242
243 https://github.com/yihui/knitr/releases/download/doc/knitr-minimal.pdf
244 \end_layout
245
246 \end_inset
247
248 .
249 The Rnw source of this document is at
250 \begin_inset Flex URL
251 status collapsed
252
253 \begin_layout Plain Layout
254
255 https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw
256 \end_layout
257
258 \end_inset
259
260 .
261 \end_layout
262
263 \end_body
264 \end_document