Why
- after you finished typing
\documentclass{beamer}
and \title{}
, I have finished my first slide with markdown
- much less commands to remember, e.g. to write bullet points, just begin with a dash “
-
” instead of \begin{itemize}
and \item
; how things can be simpler?
- I know you want math to show you are a statistician, e.g. $f(k)={n \choose k}p^{k}(1-p)^{n-k}$
- you do not need to maintain output – only maintain a source file
- HTML5/CSS3 is much more fun than LaTeX
A bit R code
head(cars)
## speed dist
## 1 4 2
## 2 4 10
## 3 7 4
## 4 7 22
## 5 8 16
## 6 9 10
cor(cars)
## speed dist
## speed 1.0000 0.8069
## dist 0.8069 1.0000
Graphics too
library(ggplot2)
## Error: there is no package called 'ggplot2'
qplot(speed, dist, data = cars) + geom_smooth()
## Error: could not find function "qplot"
How
- source editor: RStudio (perfect integration with knitr; one-click compilation); currently you have to use the version >= 0.96.109
- HTML5 slides converter: pandoc; this document was generated by:
pandoc -s -S -i -t dzslides --mathjax knitr-slides.md -o knitr-slides.html
- the file
knitr-slides.md
is the markdown output from its source: library(knitr); knit('knitr-slides.Rmd')
- or simple click the button
Knit HTML
in RStudio
For ninjas
- you should tweak the default style; why not try some Google web fonts? (think how painful it is to wrestle with fonts in LaTeX)
- pandoc provides 3 types of HTML5 slides (dzslides is one of them)
- you can tweak the default template to get better appearances
- if you have come up with a better dzslides template, please let me know or contribute to pandoc directly (e.g.
pre
blocks should have max-width
and max-height
)
For beamer lovers
- pandoc supports conversion to beamer as well. period.
For Powerpoint lovers
Reproducible research
It is good to include the session info, e.g. this document is produced with knitr. Here is my session info:
print(sessionInfo(), locale = FALSE)
## R version 2.15.2 (2012-10-26)
## Platform: x86_64-redhat-linux-gnu (64-bit)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] knitr_1.2
##
## loaded via a namespace (and not attached):
## [1] codetools_0.2-8 digest_0.6.3 evaluate_0.4.3 formatR_0.8
## [5] stringr_0.6.2 tools_2.15.2
Misc issues
- the plots are too wide? use the chunk option
out.width
which will be used in <img width=... />
, e.g. out.width=400px
Life is short
% Writing beautiful and reproducible slides quickly
% Yihui Xie
% 2012/04/30
Why
- after you finished typing
\documentclass{beamer}
and \title{}
, I have finished my first slide with markdown
- much less commands to remember, e.g. to write bullet points, just begin with a dash “
-
” instead of \begin{itemize}
and \item
; how things can be simpler?
- I know you want math to show you are a statistician, e.g. $f(k)={n \choose k}p^{k}(1-p)^{n-k}$
- you do not need to maintain output – only maintain a source file
- HTML5/CSS3 is much more fun than LaTeX
A bit R code
head(cars)
## speed dist
## 1 4 2
## 2 4 10
## 3 7 4
## 4 7 22
## 5 8 16
## 6 9 10
cor(cars)
## speed dist
## speed 1.0000 0.8069
## dist 0.8069 1.0000
Graphics too
library(ggplot2)
## Error: there is no package called 'ggplot2'
qplot(speed, dist, data = cars) + geom_smooth()
## Error: could not find function "qplot"
How
- source editor: RStudio (perfect integration with knitr; one-click compilation); currently you have to use the version >= 0.96.109
- HTML5 slides converter: pandoc; this document was generated by:
pandoc -s -S -i -t dzslides --mathjax knitr-slides.md -o knitr-slides.html
- the file
knitr-slides.md
is the markdown output from its source: library(knitr); knit('knitr-slides.Rmd')
- or simple click the button
Knit HTML
in RStudio
For ninjas
- you should tweak the default style; why not try some Google web fonts? (think how painful it is to wrestle with fonts in LaTeX)
- pandoc provides 3 types of HTML5 slides (dzslides is one of them)
- you can tweak the default template to get better appearances
- if you have come up with a better dzslides template, please let me know or contribute to pandoc directly (e.g.
pre
blocks should have max-width
and max-height
)
For beamer lovers
- pandoc supports conversion to beamer as well. period.
For Powerpoint lovers
Reproducible research
It is good to include the session info, e.g. this document is produced with knitr. Here is my session info:
print(sessionInfo(), locale = FALSE)
## R version 2.15.2 (2012-10-26)
## Platform: x86_64-redhat-linux-gnu (64-bit)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] knitr_1.2
##
## loaded via a namespace (and not attached):
## [1] codetools_0.2-8 digest_0.6.3 evaluate_0.4.3 formatR_0.8
## [5] stringr_0.6.2 tools_2.15.2
Misc issues
- the plots are too wide? use the chunk option
out.width
which will be used in <img width=... />
, e.g. out.width=400px
Life is short