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.

Preform the Data Science Task!

  territory_summary <- function(df) {
  
    df %>% 
      summarize(
        total = sum(count),
        percent_yes = sum(ifelse(resp=="yes", count, 0)) / total * 100  
      )
  
  }

  # Apply function to each territory
  aus_mar %>% 
    split(.$territory) %>% 
    map_dfr(territory_summary)
## # A tibble: 8 × 2
##     total percent_yes
##     <dbl>       <dbl>
## 1  236979        74.0
## 2 4111200        57.8
## 3   80376        60.6
## 4 2448075        60.7
## 5  948775        62.5
## 6  301603        63.6
## 7 3306727        64.9
## 8 1257499        63.7

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.