---
title: "Exercise: tidying and transforming data"
author: "Mark Dunning and Matt Eldridge"
date: '`r format(Sys.time(), "Last modified: %d %b %Y")`'
output: html_document
---

## Part I -- tidying data

1. Read in the simulated clinical dataset, `clinical-data.txt`.

```{r}

```

Take a look at the data and answer the following questions:

* What variables and observations do we have?
* What might a 'tidy' version of this dataset look like?

2. Transform the data into a tidy form using the `gather` function from the `tidyr` package.

```{r}

```

3. Display the range of values for each drug and placebo treatment as a box plot

```{r}

```

## Part II -- selecting columns

4. Read in the patients dataset

```{r}

```

5. Select all the columns between `Height` and `Grade_Level`

```{r}

```

6. Select all the columns between `Height` and `Grade_Level`, but not `State`

```{r}

```

7. Select all columns ending in 'eight', i.e. `Height` and `Weight`

```{r}

```

8. Select all columns except `Birth`, `State` and `Grade_Level`

```{r}

```

## Part III - data transformations

The study that collected the patient data is interested in the relationship between body mass index (BMI) and smoking.

Which the relevant variables (columns) in our patients dataset and what problems can you see with these columns as they currently stand?

9. Clean the `Height` and `Weight` columns to remove the 'cm' and 'kg' units respectively.

```{r}

```

10. Clean the `Smokes` column so that it contains just `TRUE` and `FALSE` values.

_Hint: use the `%in%` operator, e.g. `c("Matt", "George") %in% c("John", "Paul", "George", "Ringo")`_

```{r}

```

11. Calculate the body mass index (BMI) for each of our patients using the formula $BMI = Weight / (Height)^2$, where the weight is measured in kilograms and the height is in metres.

```{r}

```

12. Create a new variable to indicate which individuals are overweight, i.e. those with a BMI of above 25.

```{r}

```

What other problems can you find in the patients dataset?


