---
title: "Exercise 4.2"
author: "Put Your Name Here"
output:
  html_document:
    toc: true
---

<!-- You can knit this document at any time to see the draft of your answer. 
     An html file will be produced in the same folder as the Rmd file. -->

<!-- When you have completed the exercise, knit the document for the final time. -->

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  echo = TRUE,
  comment = NA,
  fig.width = 7,
  fig.height = 4,
  dpi = 130
)
```

In this exercise, we will be using functions from the `tidyverse` package and the `broom` package. More attractive tables like those seen in lectures can be produced using `gt`.

```{r packages, message = FALSE, warning = FALSE}
library(tidyverse)
library(broom)
library(gt)
```

### (a) Comparing number of trips for those with and without BRM

> We've seen the data in `airport_screening.csv` in the lectures.  We also noticed there seemed to be a relationship between number of trips and tendency to bring in Biosecurity Risk Material (BRM), but we haven't assessed it formally.

> Load the data set using `screening <- read_csv("airport_screening.csv")` and use the `t.test` function to compare the average number of trips between those people with BRM and those without. Recall that we use the `y ~ x` model syntax for two-sample t-tests like this (the data are not paired).
>
> Extract out the P-value by creating an object using `tidy()`. You could even try formatting it automatically using the `scales` package as demonstrated in lectures.

### (b) Looking at the association between passenger and crew and BRM

> Use a Fisher's exact test (`fisher.test()`) to compare the rates of BRM for passengers compared to crew.
>
> Use a Chi-squared test (`chisq.test()`) to compare the rates of BRM for the four passport countries.
>
> Use the `group_by` and `summarise` with `mean` functions to print the actual proportions of BRM in the groups, following the example in lectures, to help understand these results.

---

&copy; 2021 Statistical Consulting Centre, The University of Melbourne.
