Created
October 30, 2023 15:43
-
-
Save timriffe/da1c78f0d0ff01bf77982d43f0942acb to your computer and use it in GitHub Desktop.
quick diagnostic of INE COD data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.ine.es/jaxiT3/Tabla.htm?t=7947 | |
library(tidyverse) | |
ine <- read_tsv("Data/INE7947.csv",locale = locale(grouping_mark = ".")) | |
ine |> | |
rename(cause = `Cause of death`) |> | |
mutate(cause = if_else(cause=="001-102 I-XXII.All causes","All",cause)) |> | |
filter(!grepl("-",cause), | |
Age != "All ages") |> | |
mutate( | |
Age = if_else(Age == "Under 1 year old" ,"0",Age), | |
Age = parse_number(Age)) |> | |
group_by(Periodo, Sex, Age) |> | |
mutate(N = Total[cause == "All"], | |
margin = sum(Total[cause!="All"]), | |
UNK = N - margin, | |
garbage = sum(Total[cause%in% c("087 Senility", | |
"057 Heart failure")]), | |
bad = UNK + garbage, | |
pgarbage = garbage / N, | |
pUNK = UNK / N, | |
pbad = bad / N) |> | |
ungroup() |> | |
filter(cause == "All", | |
Periodo < 2020) |> | |
ggplot(aes(x=Periodo, y = pgarbage, color = Sex)) + | |
geom_line() + | |
facet_wrap(~Age) + | |
theme_minimal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment