Substances risk factor vs direct deaths.
I downloaded Death from Tobacco, alcohol and drugs from Our world in data. I chose this data because many younger generations don’t understand the importance of tobacco.
This is the link to the data.
The following code chunk loads the package I will use to read in and prepare the data for analysis.
substances_risk_factor_vs_direct_deaths <-
read_csv(here::here("_posts/2022-05-10-project-part-1/substances-risk-factor-vs-direct-deaths.csv"))
glimpse(substances_risk_factor_vs_direct_deaths)
Rows: 6,840
Columns: 8
$ Entity <chr> …
$ Code <chr> …
$ Year <dbl> …
$ `Deaths - Drug use disorders - Sex: Both - Age: All Ages (Number)` <dbl> …
$ `Deaths - Alcohol use disorders - Sex: Both - Age: All Ages (Number)` <dbl> …
$ `Deaths - Cause: All causes - Risk: Tobacco - Sex: Both - Age: All Ages (Number)` <dbl> …
$ `Deaths - Cause: All causes - Risk: Drug use - Sex: Both - Age: All Ages (Number)` <dbl> …
$ `Deaths - Cause: All causes - Risk: Alcohol use - Sex: Both - Age: All Ages (Number)` <dbl> …
#view(substances_risk_factor_vs_direct_deaths)
Use filter to extract the rows that I want to keep: >= 2019 world
Select the columns to keep: Dug use disorders, alcohol use disorders, Cause tobacco, cause drug use, Cause tobacco use
Assign the output to direct_deaths
Display the first 5 rows of direct_deaths
direct_deaths <-
substances_risk_factor_vs_direct_deaths %>%
filter(Year == 2019, Entity == "World") %>%
rename(drug_use_disorders = 4,
Alchohol_use_disorders = 5,
Cause_Tobacco = 6,
Cause_Drug_Use = 7,
Cause_Alchohol_Use = 8) %>%
select(4:8)
direct_deaths
# A tibble: 1 × 5
drug_use_disorders Alchohol_use_disord… Cause_Tobacco Cause_Drug_Use
<dbl> <dbl> <dbl> <dbl>
1 128083 168015 8708898 494492
# … with 1 more variable: Cause_Alchohol_Use <dbl>
The graph matches the information as only 5 rows are depicted.
Add a picture.
Project Completed with Nico Kellenberger.
write_csv(direct_deaths, file = "direct_deaths.csv")