This is a simple, minimal example of report written in R markdown. The
purpose of this report is two fold:

1. To enlighten you about the relationship between engine displacement
   and gas mileage.
2. Provide an accessible introduction to Literate Programming.

The source of the data is the 1974 Motor Trend USA Magazine.

```{r echo=FALSE}

## Init R and Config
library(ggplot2)
data(mtcars)

```

Next steps:

- Examine the two variables( engine displacement, gase mileage).
- Examine the relationship between the two variables by drawing a
  scatter plot.

# Engine Displacement

Engine displacement is measured in cubic inches. 

```{r echo=FALSE}

mtcars %>%
    select(disp) %>%
        group_by(
            "Engine Displacement" = ifelse(disp<= 100
                                          ,"0-100"
                                          ,ifelse(disp>100 & disp<= 200
                                                  ,"101-200"
                                                  ,ifelse(disp > 200 & disp <= 300
                                                          ,"201 - 300"
                                                          ,ifelse(disp>300,"300+","Error")
                                                         )
                                                 )
                                          )            
        ) %>%
            summarize(
                "N Cars" = n()
                ,"% Cars" = round(100.0*n()/dim(mtcars)[1], 2)
            ) %>%
                kable(x=.
                      ,caption="1974 Motor Trend US Magazine Engine Displacement (cubic inches)"
                      )

```

\pagebreak

# Miles Per Gallon

Miles per gallon, or fuel efficiency, is measured in miles to the
gallon, because we are in the US. 

```{r echo=FALSE}

qplot(mpg, data=mtcars, xlab="MPG", ylab="N Cars", geom="histogram", binwidth=5)

```

\pagebreak

# Scatterplot

Displacement is the independent variable. Gas mileage is the dependent
variable. Correlation does not imply causation, except for this time
when it does.

```{r echo=FALSE}

ggplot(data = mtcars, aes(x=disp, y=mpg)) + geom_point(shape=1) + geom_smooth(method=lm)

```

\newpage

# Correlation Discussion

Clearly, gas mileage is strongly correlated with engine
displacement. But how strong is it? As it turns out, the Pearson's r
is `r cor( mtcars$disp, mtcars$mpg) `.

Thank you and have a nice darned day.
