Instructions: You are an analyst for Initech Analytica (IA), a nefarious policy research company. IA has been hired by the Oat Milk Advocacy Group to create a misinformation campaign against the dairy industry. In the notes for this unit, I gave an example of lying with scatter plots using a spurious correlation between mozzarella and deaths by poisoning. Your assignment is to create a similar chart selecting a different variety of cheese (i.e., you may not use mozzarella).
Your assignment must contain the following elements:
Data: Loaded the “cheese” and “injury mortality rates for the US” datasets.
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Let’s take an overview of the data set.
## Rows: 24
## Columns: 9
## $ year <dbl> 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,…
## $ cheddar <dbl> 9.04, 9.19, 9.51, 9.60, 10.01, 9.87, 9.89, 9.76, 9.38, 10.2…
## $ mozzarella <dbl> 7.89, 8.22, 8.16, 8.33, 8.74, 9.05, 9.35, 9.38, 9.45, 9.68,…
## $ swiss <dbl> 1.09, 1.07, 0.99, 1.01, 1.09, 1.02, 1.12, 1.09, 1.13, 1.20,…
## $ blue <dbl> 0.16, 0.17, 0.18, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ brick <dbl> 0.04, 0.04, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03,…
## $ muenster <dbl> 0.41, 0.39, 0.37, 0.34, 0.28, 0.30, 0.28, 0.28, 0.27, 0.25,…
## $ neufchatel <dbl> 2.04, 2.11, 2.25, 2.20, 2.26, 2.39, 2.21, 2.33, 2.30, 2.34,…
## $ hispanic <dbl> NA, 0.25, 0.25, 0.27, 0.30, 0.33, 0.37, 0.42, 0.45, 0.48, 0…
## Rows: 98,280
## Columns: 17
## $ Year <dbl> 2016, 2015, 2014, 2013, 201…
## $ Sex <chr> "Both sexes", "Both sexes",…
## $ `Age group (years)` <chr> "All Ages", "All Ages", "Al…
## $ Race <chr> "All races", "All races", "…
## $ `Injury mechanism` <chr> "All Mechanisms", "All Mech…
## $ `Injury intent` <chr> "All Intentions", "All Inte…
## $ Deaths <dbl> 231991, 214008, 199752, 192…
## $ Population <dbl> 323127513, 321418820, 31885…
## $ `Age Specific Rate` <dbl> 71.795496, 66.582287, 62.64…
## $ `Age Specific Rate Standard Error` <dbl> 0.1490602, 0.1439275, 0.140…
## $ `Age Specific Rate Lower Confidence Limit` <dbl> 71.503338, 66.300189, 62.37…
## $ `Age Specific Rate Upper Confidence Limit` <dbl> 72.087654, 66.864384, 62.92…
## $ `Age Adjusted Rate` <dbl> 68.98224, 63.86611, 60.1272…
## $ `Age Adjusted Rate Standard Error` <dbl> 0.1460097, 0.1405070, 0.136…
## $ `Age Adjusted Rate Lower Confidence Limit` <dbl> 68.69606, 63.59072, 59.8592…
## $ `Age Adjusted Rate Upper Confidence Limit` <dbl> 69.26842, 64.14151, 60.3952…
## $ Unit <chr> "per 100,000 population", "…
Simplified the deaths data set by filtering out the variables I wanted to see in the data frame: injury mechanisms, age group, injury intent, race and both sexes and selecting only year, injury intent and death count. To create a better visualization of the data and make it easier to set up a correlation matrix I pivoted the subset into a more wide format. A new data set “death by cheese” was created using inner join with the cheese data (filtering by muenster) and the death data (filtering by year), to finally run a correlation matrix, which show me that the highest correlation value is for muenster consumption and suicide at 0.95.
## muenster Unintentional Suicide Homicide
## muenster 1.0000000 0.89182471 0.9555510 -0.25343850
## Unintentional 0.8918247 1.00000000 0.9541055 -0.03848175
## Suicide 0.9555510 0.95410552 1.0000000 -0.23414469
## Homicide -0.2534385 -0.03848175 -0.2341447 1.00000000
## Undetermined 0.2930508 0.64639007 0.4640975 0.28688435
## Legal intervention/war 0.8720061 0.82498442 0.8602972 -0.11764121
## Undetermined Legal intervention/war
## muenster 0.2930508 0.8720061
## Unintentional 0.6463901 0.8249844
## Suicide 0.4640975 0.8602972
## Homicide 0.2868843 -0.1176412
## Undetermined 1.0000000 0.3248518
## Legal intervention/war 0.3248518 1.0000000
## `geom_smooth()` using formula = 'y ~ x'