---
title: "Exercise 3"
author: "Chris Penfold"
date: "25 September, 2019"
output:
  html_document:
    df_print: paged
  word_document: default
  pdf_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Embed a plot

Here's an embedded plot

```{r plot1, error=FALSE, warning=FALSE}
library(ggplot2)
ggplot(data = mpg, aes(x = drv, 
                       y = hwy, 
                       colour = drv)) + 
  geom_boxplot()

```


## Embed a table

Here's an embedded table

```{r table1, results="asis", error=FALSE, warning=FALSE}
library(BristolVis)
library(arsenal)
table_one <- tableby(diet ~ bmi + sex, 
                     data = bmi, 
                     test=TRUE, # include tests of associations between diet and exposures
                     total=TRUE, # include a total column
                     control=tableby.control(digits=1)) # to control how many decimal places are in the table
summary(table_one)
```


## Inline R code

We included `r nrow(bmi)` people from the `BMI` dataset in our analyses. The mean BMI of people in this study was `r round(mean(bmi$bmi), 1)`kg/m^2^ (sd = `r round(sd(bmi$bmi), 1)`kg/m^2^).