May 9, 2018

Under the hood (from rmarkdown.rstudio.com)
render function from the rmarkdown package.KnitDefines the metadata of the document and parameters for the compilation.
--- title: "Introduction to R Markdown" subtitle: "MonBUG Meeting" author: "Jean Monlong" date: May 9, 2018 output: ioslides_presentation ---
# Header 1 ## Header 2 ### Header 3
Some text with a **word in bold**, another *in italic* and a [link](https://rmarkdown.rstudio.com)
Some text with a word in bold, another in italic and a link
- Bullet item 1
1. Ordered item 1
1. Ordered item 2
- Bullet item 2
- Bullet item 3
Note: 4 spaces to define sub-lists.
```{r histtest}
x = rnorm(1000)
hist(x)
```
Advice: Name your chunks.
x = rnorm(1000) hist(x)
eval=FALSE: don't run the code.echo=FALSE: don't show the output.message=FALSE: don't show the output messages.warning=FALSE: don't show the output warnings.include=FALSE: don't output anything (but code is run).fig.width=8: set the width of figures.cache=TRUE: cache the results of a chunk.tidy=TRUE: tidy the code.At the beginning of the document. For example "no code" mode:
```{r include=FALSE}
knitr::opts_chunk$set(echo=FALSE, message=FALSE,
warning=FALSE, fig.width=10)
```
Or "code+output" mode:
```{r include=FALSE}
knitr::opts_chunk$set(echo=TRUE, message=FALSE,
warning=FALSE, fig.width=10, tidy=TRUE)
```
```{r cache=TRUE}
res = reallyLongComputation(x)
hist(res)
```
dependson can specify dependency but not very practical.Apparently autodep tries to understand dependencies.
Caching manually is safer IMO.
kable functiondf
## time Rmarkdown.knowledge Rmarkdown.usage ## 1 Before MonBUG 3801 0.1123095 ## 2 After MonBUG 11543 0.2234982
library(knitr) kable(df)
| time | Rmarkdown.knowledge | Rmarkdown.usage |
|---|---|---|
| Before MonBUG | 3801 | 0.1123095 |
| After MonBUG | 11543 | 0.2234982 |
kable and its argumentskable(df, digits = 2, format.args = list(big.mark = ","),
col.names = c("Time", "RMarkdown knowledge",
"Rmarkdown usage"))
| Time | RMarkdown knowledge | Rmarkdown usage |
|---|---|---|
| Before MonBUG | 3,801 | 0.11 |
| After MonBUG | 11,543 | 0.22 |
```{r, include=FALSE}
knitr::knit_hooks$set(resize = function(before, options, envir) {
if (before) {
return('\\resizebox{\\textwidth}{!}{')
} else {
return('}')
}
})
```
## Wide table
```{r, resize=TRUE}
knitr::kable(df, format='latex')
```
--- output: md_document ---
For GitHub/Bitbucket pages or wikis.
---
output:
md_document:
variant: markdown_github
---
---
title: "Your title"
output:
html_document:
toc: true
---
Customizable themes and cool features:
toc).toc_float).code_folding).--- title: "Introduction to R Markdown" subtitle: "MonBUG Meeting" author: "Jean Monlong" date: May 9, 2018 output: beamer_presentation ---
Trick: use PNG image types to reduce PDF size (sometimes).
output:
beamer_presentation:
dev: png
Remove navigation bar and add page numbers
---
output:
beamer_presentation:
includes:
in_header: header.tex
---
And in header.tex:
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[page number]
.md file and _files folder (with images).index.html and switch on GitHub Pages..bib files.blogdown package.