Interactive and static plots of United States deaths per drug from 1990 to 2015.
1.) Packages I will use to read in and plot the data.
2.) Read in the data from Part 1
mutate
to create dates on the x-axise_charts
to an e_charts object with Year on the X-axise_line
to create lines for Cocaine, Opioid, Alcohol, Amphetamine, and Other_drugslegend = FALSE
following each variable to remove them from legende_tooltip
to add a tooltip that will display based on the axis valuese_title
to add a title, subtitle, and link to subtitledeaths_per_drug %>%
mutate(Year = paste(Year, "12", "31", sep = "-")) %>%
e_charts(x = Year) %>%
e_line(Cocaine, legend = FALSE) %>%
e_line(Opioid, legend = FALSE) %>%
e_line(Alcohol, legend = FALSE) %>%
e_line(Amphetamine, legend = FALSE) %>%
e_line(Other_Drugs, legend = FALSE) %>%
e_tooltip(trigger = "axis") %>%
e_title(text = "Deaths per Drug Abuse in America",
subtext = "(Per every 5 years), Source: Our World in Data",
sublink = "https://ourworldindata.org/grapher/deaths-substance-disorders?time=1990..2019&country=~USA")
Save the previous plot to preview.png
and add to the yaml chunk at the top