Debian Codegraph @

inst/examples/knitr-minimal.Rnw

raw
1 %% LyX 2.2.1 created this file. For more info, see http://www.lyx.org/.
2 %% Do not edit unless you really know what you are doing.
3 \documentclass{article}
4 \usepackage[sc]{mathpazo}
5 \usepackage[T1]{fontenc}
6 \usepackage{geometry}
7 \geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
8 \setcounter{secnumdepth}{2}
9 \setcounter{tocdepth}{2}
10 \usepackage{url}
11 \usepackage[unicode=true,pdfusetitle,
12 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,
13 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
14 {hyperref}
15 \hypersetup{
16 pdfstartview={XYZ null null 1}}
17 \usepackage{breakurl}
18 \begin{document}
19 <<setup, include=FALSE, cache=FALSE>>=
20 library(knitr)
21 # set global chunk options
22 opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold')
23 options(formatR.arrow=TRUE,width=90)
24 @
25
26 \title{A Minimal Demo of knitr}
27
28 \author{Yihui Xie}
29
30 \maketitle
31 You can test if \textbf{knitr} works with this minimal demo. OK, let's
32 get started with some boring random numbers:
33
34 <<boring-random>>=
35 set.seed(1121)
36 (x=rnorm(20))
37 mean(x);var(x)
38 @
39
40 The first element of \texttt{x} is \Sexpr{x[1]}. Boring boxplots
41 and histograms recorded by the PDF device:
42
43 <<boring-plots, fig.width=4, fig.height=4, out.width='.4\\linewidth'>>=
44 ## two plots side by side (option fig.show='hold')
45 par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3,las=1)
46 boxplot(x)
47 hist(x,main='')
48 @
49
50 Do the above chunks work? You should be able to compile the \TeX{}
51 document and get a PDF file like this one: \url{https://github.com/yihui/knitr/releases/download/doc/knitr-minimal.pdf}.
52 The Rnw source of this document is at \url{https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw}.
53 \end{document}