install.packages("rmarkdown")
## This one's just for making plots later
install.packages("gapminder")
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
block quote
> block quote
Bold
**Bold**
Italic
*Italic*
endash: –
endash: --
emdash: —
emdash: ---
inline equation (using \(LaTeX\)): \(A = \pi*r^{2}\)
inline equation (using $LaTeX$): $A = \pi*r^{2}$
Subscripts Hello! and superscripts Hello! are easy.
Subscripts ~Hello!~ and superscripts ^Hello!^ are easy.
[Here's a link](https://www.google.com)
image:
image: 
* unordered list
* number 2
+ sub-item (four spaces)
1. ordered list
2. item 2
+ sub-item (four spaces)
The default rendering is as you would see in the R terminal:
head(mtcars)
## mpg cyl disp hp drat wt qsec vs am gear carb
## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
## Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
## Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
## Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
## Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
You can use other styles, including interactive tables when knitting to HTML. Here’s one using a knitr kable:
knitr::kable(head(mtcars))
| mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Mazda RX4 | 21.0 | 6 | 160 | 110 | 3.90 | 2.620 | 16.46 | 0 | 1 | 4 | 4 |
| Mazda RX4 Wag | 21.0 | 6 | 160 | 110 | 3.90 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |
| Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.320 | 18.61 | 1 | 1 | 4 | 1 |
| Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 |
| Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.440 | 17.02 | 0 | 0 | 3 | 2 |
| Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.460 | 20.22 | 1 | 0 | 3 | 1 |
Here’s a piece of inline code to look at.
Here's a piece of `inline code` to look at.
Here is a piece of inline R code: 10
Here is a piece of inline R code: `r sum(3, 7)`
```
Code chunks are delineated by three backticks
```
# R Code goes here!!
# This will generate output
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
# Including "eval = FALSE" means this code will not run
summary(cars)
# Throw some plots in:
library(ggplot2)
library(gapminder)
ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) +
geom_point(aes(color = continent))
# Reproducible reports for when your data changes:
library(MASS)
library(ggplot2)
set.seed(42)
df <- data.frame(mvrnorm(500, mu = c(0,0), Sigma = matrix(c(1,0.56,0.56,1), ncol = 2),
empirical = TRUE))
head(df)
## X1 X2
## 1 -1.5229629 -0.1039770
## 2 -0.6037383 -1.0562666
## 3 -0.1830964 0.1967777
## 4 -0.4197538 0.2290691
## 5 0.4354155 0.8071503
## 6 0.1885482 0.1035446
ggplot(df, aes(x = X1, y = X2)) +
geom_point() +
geom_smooth(method = "lm")
set.seed(500)
df <- data.frame(mvrnorm(500, mu = c(0,0), Sigma = matrix(c(1,0.56,0.56,1), ncol = 2),
empirical = TRUE))
head(df)
## X1 X2
## 1 -2.2014050 -0.6368717
## 2 -1.3510351 -1.9537550
## 3 0.7808272 -1.2277939
## 4 0.9720240 -0.3084019
## 5 0.3479552 -1.1997703
## 6 0.4815081 0.4875031
ggplot(df, aes(x = X1, y = X2)) +
geom_point() +
geom_smooth(method = "lm")
Code chunks can be in other languages including:
x = 'hello, world!'
print(x.split(' '))
## ['hello,', 'world!']
Here’s a footnote,1 and a second one. 2
Here's a footnote,[^1] and a second one. [^longnamednote]
[^1]: Here's the first footnote.
[^longnamednote]: Here's the other.
The Rmd used to produce this can be found here.