Skip to content

Instantly share code, notes, and snippets.

@kippjohnson
Created November 14, 2018 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kippjohnson/bc76f5cd1f8af3d865355a292d5ed8f3 to your computer and use it in GitHub Desktop.
Save kippjohnson/bc76f5cd1f8af3d865355a292d5ed8f3 to your computer and use it in GitHub Desktop.
library(data.table)
library(ggplot2)
library(ggsci)
dat <- fread("~/Downloads/neoplasm_vs_circulatory_mortality_parsed.txt")
colnames(dat) <- c("V0", "Gender", "GenderCode", "CauseOfDeath", "ICD", "Year", "Year1", "Deaths", "Population", "CrudeRate","AgeAdjustedRate")
dat$Cause <- plyr::mapvalues(dat$CauseOfDeath, from=c("Diseases of the circulatory system","Neoplasms"), to=c("Circulatory\nSystem","Neoplasm"))
ggplot(dat, aes(x=Year, y=CrudeRate, color=Gender, linetype=Cause)) +
geom_line() +
theme_bw() +
scale_color_aaas() +
labs(x="Year", y="Death Rate", title="Crude Death Rate")
ggplot(dat, aes(x=Year, y=AgeAdjustedRate, color=Gender, linetype=Cause)) +
geom_line() +
theme_bw() +
scale_color_aaas() +
labs(x="Year", y="Death Rate", title="Age-adjusted Death Rate")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment