Read in a dataset

For this challenge I will be using the Australian Marriage Dataset.

aus_mar <- read_csv("../challenge_datasets/australian_marriage_tidy.csv")
## Rows: 16 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): territory, resp
## dbl (2): count, percent
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Create Function

## # A tibble: 8 × 4
##   territory                           yes   total percentage
##   <chr>                             <dbl>   <dbl>      <dbl>
## 1 Australian Capital Territory(c)  175459  236979       74.0
## 2 New South Wales                 2374362 4111200       57.8
## 3 Northern Territory(b)             48686   80376       60.6
## 4 Queensland                      1487060 2448075       60.7
## 5 South Australia                  592528  948775       62.5
## 6 Tasmania                         191948  301603       63.6
## 7 Victoria                        2145629 3306727       64.9
## 8 Western Australia                801575 1257499       63.7

Function Explanation

This function computes the percentage of yes votes for same sex marriage based on territory!