#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{multicol, upquote}
% \VignetteIndexEntry{knitr Reference Card}
% \VignetteEngine{knitr}
\end_preamble
\use_default_options true
\begin_modules
knitr
\end_modules
\maintain_unincluded_children false
\language english
\language_package none
\inputencoding default
\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 true
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks false
\pdf_backref false
\pdf_pdfusetitle true
\papersize default
\use_geometry true
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation landscape
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1cm
\topmargin 0cm
\rightmargin 1cm
\bottommargin 0cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip 0in
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
knitr Reference Card
\end_layout

\begin_layout Author
Yihui Xie
\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
begin{multicols}{2}
\end_layout

\end_inset


\end_layout

\begin_layout Section
Syntax
\end_layout

\begin_layout Standard
\noindent
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="7" columns="5">
<features tabularvalignment="middle">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<row>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
format
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
start
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
end
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
inline
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
output
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Rnw
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|<<*>>=|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\family typewriter
@
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|
\backslash
|
\backslash
verb|Sexpr{x}|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
TeX
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Rmd
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|```{r *}|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|```|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|`r x`|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
MD
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Rhtml
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|<!--begin.rcode *|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|end.rcode-->|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|<!--rinline x-->|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
HTML
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Rrst
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\family typewriter
..
\begin_inset space ~
\end_inset

{r *}
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\family typewriter
..
\begin_inset space ~
\end_inset

..
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|:r:`x`|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
reST
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Rtex
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\family typewriter
% begin.rcode *
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\family typewriter
% end.rcode
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|
\backslash
rinline{x}|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
TeX
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
brew
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|<% x %>|
\end_layout

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
text
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\begin_layout Standard

\family typewriter
*
\family default
 denotes local chunk options, e.g.
 
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|<<label, eval=FALSE>>=|
\end_layout

\end_inset

; 
\family typewriter
x
\family default
 denotes inline R code, e.g.
 
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
verb|`r 1+2`|
\end_layout

\end_inset

 (MD stands for 
\begin_inset CommandInset href
LatexCommand href
name "Markdown"
target "http://en.wikipedia.org/wiki/Markdown"

\end_inset

)
\end_layout

\begin_layout Section
Minimal Examples
\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
begin{multicols}{2}
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Sweave (*.Rnw)
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

<<echo=FALSE>>=
\end_layout

\begin_layout Plain Layout

x=paste('
\backslash

\backslash
Sexpr', '{', 'z}', sep = '')
\end_layout

\begin_layout Plain Layout

@
\end_layout

\begin_layout Plain Layout


\backslash
begin{verbatim}
\end_layout

\begin_layout Plain Layout


\backslash
document
\backslash
Sexpr{'c'}lass{article}
\end_layout

\begin_layout Plain Layout


\backslash
be
\backslash
Sexpr{'g'}in{document}
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

Below is a code chunk.
\end_layout

\begin_layout Plain Layout


\backslash
Sexpr{''}<<foo, echo=TRUE>>=
\end_layout

\begin_layout Plain Layout

z = 1+1
\end_layout

\begin_layout Plain Layout

plot(cars)
\end_layout

\begin_layout Plain Layout


\backslash
Sexpr{''}@
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

The value of z is 
\backslash
Sexpr{x}.
\end_layout

\begin_layout Plain Layout


\backslash
end{document}
\end_layout

\begin_layout Plain Layout


\backslash
end{verbatim}
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
R Markdown (*.Rmd)
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
begin{verbatim}
\end_layout

\begin_layout Plain Layout

Hi _markdown_!
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

```{r foo, echo=TRUE}
\end_layout

\begin_layout Plain Layout

z = 1+1
\end_layout

\begin_layout Plain Layout

plot(cars)
\end_layout

\begin_layout Plain Layout

```
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

The value of z is `r z`.
\end_layout

\begin_layout Plain Layout


\backslash
end{verbatim}
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Brew (*.brew)
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
begin{verbatim}
\end_layout

\begin_layout Plain Layout

The value of pi is <% pi %>.
\end_layout

\begin_layout Plain Layout


\backslash
end{verbatim}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
end{multicols}
\end_layout

\end_inset


\end_layout

\begin_layout Section
Chunk Options
\end_layout

\begin_layout Standard

\family typewriter
opts_chunk
\family default
 controls global chunk options, e.g.
 
\family typewriter
opts_chunk$set(tidy = FALSE)
\family default
, which can be overridden by local chunk options.
 See all options at 
\begin_inset Flex URL
status collapsed

\begin_layout Plain Layout

http://yihui.name/knitr/options
\end_layout

\end_inset

; some frequently used options:
\end_layout

\begin_layout Description
eval whether to evaluate the chunk
\end_layout

\begin_layout Description
echo whether to echo source code
\end_layout

\begin_layout Description
results 
\family typewriter
'markup'
\family default
, 
\family typewriter
'asis'
\family default
, 
\family typewriter
'hide'
\end_layout

\begin_layout Description
tidy whether to reformat R code
\end_layout

\begin_layout Description
cache whether to cache results
\end_layout

\begin_layout Description
fig.width,
\begin_inset space \space{}
\end_inset

fig.height,
\begin_inset space \space{}
\end_inset

out.width,
\begin_inset space \space{}
\end_inset

out.height device and output size of figures
\end_layout

\begin_layout Description
include whether to include the chunk results in output
\end_layout

\begin_layout Description
child filenames of child documents
\end_layout

\begin_layout Description
engine language name (R, python, ...)
\end_layout

\begin_layout Section
Functions
\end_layout

\begin_layout Description
knit() the main function in this package; knit input document and write
 output
\end_layout

\begin_layout Description
purl() extract R code from an input document
\end_layout

\begin_layout Description
spin() spin goat's hair (an R script with roxygen comments) into wool (a
 literate programming document to be passed to 
\family typewriter
knit()
\family default
)
\end_layout

\begin_layout Description
stitch() insert an R script into a template and compile the document
\end_layout

\begin_layout Description
knit_hooks$set() set or reset chunk and output 
\begin_inset CommandInset href
LatexCommand href
name "hooks"
target "http://yihui.name/knitr/hooks"

\end_inset


\end_layout

\begin_layout Section
Resources
\end_layout

\begin_layout Itemize
homepage: 
\begin_inset Flex URL
status collapsed

\begin_layout Plain Layout

http://yihui.name/knitr
\end_layout

\end_inset

 
\end_layout

\begin_layout Itemize
development repository: 
\begin_inset Flex URL
status collapsed

\begin_layout Plain Layout

https://github.com/yihui/knitr
\end_layout

\end_inset

 (
\begin_inset CommandInset href
LatexCommand href
name "CRAN"
target "http://cran.r-project.org/package=knitr"

\end_inset

, 
\begin_inset CommandInset href
LatexCommand href
name "Rforge"
target "http://rforge.net/knitr"

\end_inset

)
\end_layout

\begin_layout Itemize
examples: 
\begin_inset Flex URL
status collapsed

\begin_layout Plain Layout

https://github.com/yihui/knitr-examples
\end_layout

\end_inset


\end_layout

\begin_layout Itemize
stackoverflow: 
\begin_inset Flex URL
status collapsed

\begin_layout Plain Layout

http://stackoverflow.com/questions/tagged/knitr
\end_layout

\end_inset


\end_layout

\begin_layout Itemize
mailing list: 
\begin_inset Flex URL
status collapsed

\begin_layout Plain Layout

https://groups.google.com/group/knitr
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
end{multicols}
\end_layout

\end_inset


\end_layout

\end_body
\end_document
