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

## Part I -- Workflows using pipes

1. Read in the patients dataset and rewrite the following cleaning steps as a workflow using the `%>%` operator.

```{r eval = FALSE}
library(tidyverse)
patients <- read_tsv("patient-data.txt")
patients <- mutate(patients, Smokes = Smokes %in% c("TRUE", "Yes"))
patients <- mutate(patients, Height = as.numeric(str_remove(Height, pattern = "cm$")))
patients <- mutate(patients, Weight = as.numeric(str_remove(Weight, pattern = "kg$")))
patients <- mutate(patients, BMI = Weight / (Height / 100) ** 2)
patients <- mutate(patients, Overweight = BMI > 25)
```

```{r}

```

2. Add a step to the workflow to round the Height, Weight and BMI to 1 decimal place.

```{r}

```

## Part II - Filtering rows

3. Filter for female patients from New York or New Jersey.

```{r}

```

4. Filter for overweight smokers that are still alive.

```{r}

```
