]> git.lyx.org Git - lyx.git/blob - lib/examples/knitr.lyx
French translation of Customization manual : final update
[lyx.git] / lib / examples / knitr.lyx
1 #LyX 2.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 544
3 \begin_document
4 \begin_header
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/
7 \textclass article
8 \use_default_options true
9 \begin_modules
10 knitr
11 \end_modules
12 \maintain_unincluded_children false
13 \language english
14 \language_package default
15 \inputencoding auto
16 \fontencoding global
17 \font_roman "palatino" "default"
18 \font_sans "lmss" "default"
19 \font_typewriter "lmtt" "default"
20 \font_math "auto" "auto"
21 \font_default_family default
22 \use_non_tex_fonts false
23 \font_sc false
24 \font_osf false
25 \font_sf_scale 100 100
26 \font_tt_scale 100 100
27 \use_microtype false
28 \use_dash_ligatures false
29 \graphics default
30 \default_output_format default
31 \output_sync 0
32 \bibtex_command default
33 \index_command default
34 \paperfontsize default
35 \spacing single
36 \use_hyperref false
37 \papersize default
38 \use_geometry true
39 \use_package amsmath 1
40 \use_package amssymb 1
41 \use_package cancel 1
42 \use_package esint 1
43 \use_package mathdots 1
44 \use_package mathtools 1
45 \use_package mhchem 1
46 \use_package stackrel 1
47 \use_package stmaryrd 1
48 \use_package undertilde 1
49 \cite_engine basic
50 \cite_engine_type default
51 \biblio_style plain
52 \use_bibtopic false
53 \use_indices false
54 \paperorientation portrait
55 \suppress_date false
56 \justification true
57 \use_refstyle 1
58 \use_minted 0
59 \index Index
60 \shortcut idx
61 \color #008000
62 \end_index
63 \leftmargin 2.5cm
64 \topmargin 2.5cm
65 \rightmargin 2.5cm
66 \bottommargin 2.5cm
67 \secnumdepth 3
68 \tocdepth 3
69 \paragraph_separation indent
70 \paragraph_indentation default
71 \is_math_indent 0
72 \math_numbering_side default
73 \quotes_style english
74 \dynamic_quotes 0
75 \papercolumns 1
76 \papersides 1
77 \paperpagestyle default
78 \tracking_changes false
79 \output_changes false
80 \html_math_output 0
81 \html_css_as_file 0
82 \html_be_strict false
83 \end_header
84
85 \begin_body
86
87 \begin_layout Title
88 Using knitr with \SpecialChar LyX
89
90 \end_layout
91
92 \begin_layout Author
93 Yihui Xie
94 \begin_inset Foot
95 status collapsed
96
97 \begin_layout Plain Layout
98 Department of Statistics, Iowa State University.
99  Email: 
100 \begin_inset CommandInset href
101 LatexCommand href
102 name "xie@yihui.name"
103 target "xie@yihui.name"
104 type "mailto:"
105 literal "false"
106
107 \end_inset
108
109
110 \end_layout
111
112 \end_inset
113
114
115 \end_layout
116
117 \begin_layout Standard
118 The R (
119 \begin_inset Flex URL
120 status collapsed
121
122 \begin_layout Plain Layout
123
124 http://www.r-project.org
125 \end_layout
126
127 \end_inset
128
129 ) package 
130 \series bold
131 knitr
132 \series default
133  is an alternative tool to Sweave based on a different design with more
134  features.
135  \SpecialChar LyX
136  has native support to Sweave since version 2.0.0, and the support to 
137 \series bold
138 knitr
139 \series default
140  was also added since 2.0.3.
141  The usage is basically the same as the 
142 \family sans
143 Sweave
144 \family default
145  module
146 \begin_inset Foot
147 status open
148
149 \begin_layout Plain Layout
150 read the \SpecialChar LyX
151 /Sweave manual from 
152 \family sans
153 Help\SpecialChar menuseparator
154 Specific Manuals
155 \end_layout
156
157 \end_inset
158
159 :
160 \end_layout
161
162 \begin_layout Enumerate
163 Open a new \SpecialChar LyX
164  document;
165 \end_layout
166
167 \begin_layout Enumerate
168 Go to 
169 \family sans
170 Document\SpecialChar menuseparator
171 Settings\SpecialChar menuseparator
172 Modules
173 \family default
174  and insert the module named 
175 \family sans
176 Rnw (knitr)
177 \family default
178 ;
179 \end_layout
180
181 \begin_layout Enumerate
182 Then insert R code in the document with either 
183 \family sans
184 Insert\SpecialChar menuseparator
185 \SpecialChar TeX
186  Code
187 \family default
188  or the 
189 \family sans
190 Chunk
191 \family default
192  environment;
193 \end_layout
194
195 \begin_layout Standard
196 The package website 
197 \begin_inset Flex URL
198 status collapsed
199
200 \begin_layout Plain Layout
201
202 http://yihui.name/knitr
203 \end_layout
204
205 \end_inset
206
207  has full documentation and demos of 
208 \series bold
209 knitr
210 \series default
211 ; many of the examples have links to the \SpecialChar LyX
212  source documents.
213 \end_layout
214
215 \begin_layout Standard
216 Since \SpecialChar LyX
217  2.3, it is necessary to enable the use of 
218 \emph on
219 needauth
220 \emph default
221  converters in
222 \family sans
223  Preferences\SpecialChar menuseparator
224 File Handling\SpecialChar menuseparator
225 Converters
226 \family default
227  in order to compile with 
228 \series bold
229 knitr
230 \series default
231 .
232 \end_layout
233
234 \begin_layout Standard
235 Note the 
236 \series bold
237 knitr
238 \series default
239  package requires R >= 2.14.1, so you need to update R if you are using an
240  old version of R.
241  Here we show one chunk as a simple example:
242 \end_layout
243
244 \begin_layout Standard
245 \begin_inset Flex Chunk
246 status open
247
248 \begin_layout Plain Layout
249
250 \begin_inset Argument 1
251 status open
252
253 \begin_layout Plain Layout
254
255 show-off
256 \end_layout
257
258 \end_inset
259
260
261 \end_layout
262
263 \begin_layout Plain Layout
264
265 rnorm(5)
266 \end_layout
267
268 \begin_layout Plain Layout
269
270 df=data.frame(y=rnorm(100), x=1:100)
271 \end_layout
272
273 \begin_layout Plain Layout
274
275 summary(lm(y~x, data=df))
276 \end_layout
277
278 \end_inset
279
280
281 \end_layout
282
283 \begin_layout Standard
284 Please contact the package author in case of any problems.
285 \end_layout
286
287 \end_body
288 \end_document