Starting to work on formats chapter

This commit is contained in:
hadley
2016-08-22 17:28:29 -05:00
parent 5de327e367
commit 0875f55510
4 changed files with 153 additions and 215 deletions

View File

@@ -1,118 +1,42 @@
---
title: "Review Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
title: "Diamonds distribution dashboard"
output: flexdashboard::flex_dashboard
---
```{r include = FALSE}
library(viridis)
```{r setup, include = FALSE}
library(ggplot2)
library(marmap)
library(dplyr)
knitr::opts_chunk$set(fig.width = 5, fig.asp = 1/3)
```
# Intro {.sidebar}
This dashboard covers several topics:
* The marmap package
* The viridis package
* Miscellaneous material
# Marmap Package
## Column 1
### Florida
### Carat
```{r echo = FALSE}
data(florida)
autoplot(florida)
```{r}
ggplot(diamonds, aes(carat)) + geom_histogram(binwidth = 0.1)
```
The [marmap](https://cran.r-project.org/web/packages/marmap/index.html) package provides tools and data for visualizing the ocean floor. Here is an example contour plot of marmap's `florida` dataset.
### Cut
## Column 2
### Hawaii
```{r echo = FALSE}
data(hawaii)
autoplot(hawaii)
```{r}
ggplot(diamonds, aes(cut)) + geom_bar()
```
### Alaska
### Colour
```{r echo = FALSE}
data(aleutians)
autoplot(aleutians)
```
# Viridis Package
## Column 1
### Viridis colors
```{r fig.cap="Maunga Whao, Auckland, NZ"}
image(volcano, col = viridis(200))
```
### Magma colors
```{r fig.cap="Maunga Whao, Auckland, NZ"}
image(volcano, col = viridis(200, option = "A"))
```{r}
ggplot(diamonds, aes(color)) + geom_bar()
```
## Column 2
### Inferno colors
### The largest diamonds
```{r fig.cap="Maunga Whao, Auckland, NZ"}
image(volcano, col = viridis(200, option = "B"))
```{r}
diamonds %>%
arrange(desc(carat)) %>%
head(100) %>%
select(carat, cut, color, price) %>%
DT::datatable()
```
### Plasma colors
```{r fig.cap="Maunga Whao, Auckland, NZ"}
image(volcano, col = viridis(200, option = "C"))
```
# Miscellaneous
## Column 1 {data-width=300}
### Bash support
```{bash}
ls *.Rmd
```
***
This chunk executes bash code.
### Python support
```{python}
x = 'hello, python world!'
print(x.split(' '))
```
***
This chunk executes python code.
## Column 2 {data-width=700}
### Tables with Kable
```{r echo = FALSE, results = 'asis'}
library(knitr)
kable(mtcars[1:5, ], caption = "A knitr kable.")
```
***
It is very easy to make tables with knitr's `kable` function.