---
output:
  html_document: default
  word_document: default
  pdf_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```

# I am a large section

## I am a smaller section


## Let's make a table

```{r}
df = data.frame(y = rnorm(1000),
           x = sample(letters, size = 1000, 
                      replace = TRUE),
           stringsAsFactors = FALSE)
df$y[ sample(1:1000, size = 20)] = NA
summ = df %>% 
  group_by(x) %>% 
  summarize(mean = mean(y, na.rm = TRUE),
            sd = sd(y, na.rm = TRUE),
            not_missing = sum(!is.na(y)),
            n =n())
summ = summ %>% 
  filter(x %in% letters[1:5])
```

```{r}
library(knitr)
library(kableExtra)
summ$z = "Hey I am a very long string and I  want to be wrapped"
knitr::kable(summ, digits = 2)
```

```{r}
library(plotly)
url = "http://johnmuschelli.com/intro_to_r/data/kaggleCarAuction.csv"
## best answer - quick and simple
cars = read_csv(
  url,
  col_types = cols(
    VehBCost = col_double()
  ))
g = ggplot(cars, aes(x = VehYear, y = VehBCost, 
                 colour = Make)) + 
  geom_boxplot() + guides(colour = FALSE)
print(g)
```


## Let's use plotly to get an interactive graph

```{r}
ggplotly(g)
```


```{r}
ss = summ %>% as.data.frame
library(pander)
pander(ss, round = 2)
```


```{r}
library(DT)
datatable(summ) %>% formatRound(columns = c("mean", "sd"))
```


Look at http://rmarkdown.rstudio.com/lesson-7.html and the Rmd: http://rmarkdown.rstudio.com/demos/6-tables.Rmd


