-
Notifications
You must be signed in to change notification settings - Fork 10
/
simple-r-markdown.rmd
34 lines (27 loc) · 1.05 KB
/
simple-r-markdown.rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
title: "R Markdown rocks"
author: "Jenny Bryan"
date: "10 September, 2014"
output:
html_document:
keep_md: TRUE
---
This is an R Markdown document.
```{r}
x <- rnorm(1000)
head(x)
```
See how the R code gets executed and a representation thereof appears in the document? `knitr` gives you control over how to represent all conceivable types of output. In case you care, then average of the `r length(x)` random normal variates we just generated is `r round(mean(x), 3)`. Those numbers are NOT hard-wired but are computed on-the-fly. As is this figure. No more copy-paste ... copy-paste ... oops forgot to copy-paste.
```{r simple-density-plot}
plot(density(x))
```
Note that all the previously demonstrated math typesetting still works. You don't have to choose between having math cred and being web-friendly!
Inline equations, such as ... the average is computed as $\frac{1}{n} \sum_{i=1}^{n} x_{i}$. Or display equations like this:
$$
\begin{equation*}
|x|=
\begin{cases} x & \text{if $x≥0$,} \\\\
-x &\text{if $x\le 0$.}
\end{cases}
\end{equation*}
$$