Created
December 3, 2023 03:49
-
-
Save thoughtfulbloke/bb30fab81127c8526af33e3f496f6733 to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: It looks like row 56 should actually have 20 columns, instead of 1 in line 55.
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
"Age-specific death rates by sex, December years (total population) (Annual-Dec)","","","","","","","","","","","","","","","","","","","" | |
"","Total Population","","","","","","","","","","","","","","","","","","" | |
" ","0-4 Years","5-9 Years","10-14 Years","15-19 Years","20-24 Years","25-29 Years","30-34 Years","35-39 Years","40-44 Years","45-49 Years","50-54 Years","55-59 Years","60-64 Years","65-69 Years","70-74 Years","75-79 Years","80-84 Years","85-89 Years","90 Years and Over" | |
1971,4.31,0.39,0.35,0.96,1.06,0.97,1.29,1.81,2.93,4.70,7.50,12.19,19.17,29.34,44.81,71.51,118.74,192.62,280.73 | |
1972,4.04,0.37,0.33,1.16,1.13,0.89,1.19,1.71,2.65,4.51,7.33,11.72,19.32,29.64,45.89,74.35,118.35,187.90,309.62 | |
1973,3.99,0.42,0.35,1.22,1.24,0.98,1.17,1.86,2.70,4.76,7.26,12.57,18.57,30.31,45.92,72.05,114.84,190.45,320.67 | |
1974,3.68,0.38,0.43,1.16,1.06,1.04,1.15,1.76,2.96,4.74,7.51,11.68,19.02,28.10,46.32,70.63,111.84,190.96,314.86 | |
1975,3.78,0.46,0.34,1.02,1.11,1.01,1.17,1.75,2.64,4.60,7.39,11.07,19.04,27.29,45.13,65.78,106.28,186.23,317.53 | |
1976,3.24,0.31,0.37,1.07,1.21,0.92,1.00,1.58,2.89,4.62,7.08,11.66,17.77,27.99,46.15,69.86,103.70,175.67,313.66 | |
1977,3.36,0.41,0.38,1.30,1.41,1.22,1.23,1.62,2.97,4.76,7.26,11.25,18.00,28.07,44.99,68.86,103.68,170.02,311.36 | |
1978,3.16,0.31,0.34,1.05,1.20,1.01,1.04,1.60,2.72,4.73,6.93,10.82,17.72,26.51,43.33,64.53,93.57,158.39,288.91 | |
1979,3.06,0.32,0.32,1.01,1.15,1.03,1.01,1.51,2.42,4.38,7.01,10.84,17.74,27.03,43.65,67.42,99.84,153.49,302.65 | |
1980,3.07,0.33,0.32,0.97,1.28,1.21,1.07,1.43,2.23,4.27,6.40,10.97,17.59,28.72,42.98,70.96,108.41,162.38,362.58 | |
1981,2.99,0.27,0.32,1.03,1.20,0.90,1.08,1.34,2.51,4.09,6.43,10.69,15.98,26.51,40.62,62.22,97.34,152.78,254.43 | |
1982,2.88,0.30,0.24,0.95,1.23,0.98,1.13,1.47,2.26,4.08,6.24,10.69,16.37,26.07,40.33,60.81,99.23,149.58,251.72 | |
1983,2.97,0.30,0.30,0.93,1.31,0.91,1.03,1.34,2.19,3.81,5.90,10.17,16.24,25.81,40.13,63.60,100.46,149.75,247.94 | |
1984,2.85,0.28,0.28,0.91,1.09,0.90,1.14,1.22,2.17,3.38,6.17,9.98,15.23,24.18,39.16,61.48,92.86,145.21,234.52 | |
1985,2.67,0.33,0.32,1.01,1.12,1.09,0.97,1.27,2.15,3.76,6.10,10.15,16.13,25.08,39.83,64.46,99.45,165.65,286.28 | |
1986,2.89,0.26,0.34,1.03,1.25,1.08,1.13,1.44,2.00,3.24,6.13,9.73,15.90,24.11,39.43,62.27,96.59,143.03,245.88 | |
1987,2.59,0.28,0.34,1.06,1.34,1.11,1.12,1.35,1.88,3.38,6.39,9.69,15.20,24.23,39.41,60.71,95.43,149.66,243.71 | |
1988,2.81,0.27,0.29,0.98,1.34,1.11,1.12,1.37,2.03,3.22,5.56,9.06,15.21,23.48,36.92,60.05,95.38,154.18,245.90 | |
1989,2.64,0.27,0.27,1.12,1.34,1.02,1.06,1.29,2.01,3.23,5.70,8.41,14.72,22.62,36.16,57.66,91.72,143.29,249.75 | |
1990,2.27,0.22,0.24,1.03,1.38,1.09,1.05,1.26,1.93,3.20,5.34,8.95,14.00,22.10,35.52,54.05,87.56,131.95,232.98 | |
1991,2.06,0.24,0.26,0.83,1.12,0.94,1.01,1.44,1.95,2.99,4.84,7.97,13.20,21.07,32.48,51.72,85.23,132.42,231.06 | |
1992,1.80,0.26,0.29,0.87,1.13,0.98,0.95,1.30,1.67,2.85,4.94,8.09,12.85,20.94,32.37,51.75,87.75,139.42,231.53 | |
1993,1.80,0.16,0.21,0.91,1.15,0.92,0.88,1.23,1.91,2.59,4.88,7.83,12.56,19.92,31.67,52.59,83.03,136.12,231.29 | |
1994,1.68,0.19,0.19,0.74,0.95,0.95,1.01,1.17,1.68,2.46,4.67,7.25,12.24,19.48,31.32,49.51,82.05,133.33,234.08 | |
1995,1.60,0.19,0.22,0.83,1.15,1.04,0.97,1.12,1.64,2.74,4.82,7.40,12.01,19.68,30.93,50.13,79.73,134.30,246.35 | |
1996,1.71,0.18,0.25,0.95,0.95,0.96,1.02,1.14,1.37,2.77,4.38,7.08,12.55,19.35,30.56,48.44,82.04,135.07,246.72 | |
1997,1.63,0.16,0.22,0.88,0.88,0.99,0.99,1.06,1.69,2.49,4.34,6.90,11.07,18.78,28.76,44.42,78.83,127.62,235.86 | |
1998,1.35,0.17,0.26,0.77,0.84,0.87,0.93,1.12,1.71,2.26,3.71,6.63,10.99,17.33,26.53,43.22,71.66,117.11,216.60 | |
1999,1.37,0.13,0.23,0.73,0.85,0.87,0.87,1.09,1.59,2.39,3.83,6.76,11.13,17.02,28.06,45.85,74.54,127.90,244.23 | |
2000,1.52,0.16,0.21,0.61,0.74,0.88,0.91,0.99,1.53,2.36,3.65,6.14,9.56,16.44,25.85,42.52,69.84,116.31,214.01 | |
2001,1.32,0.16,0.21,0.69,0.81,0.76,0.91,0.99,1.46,2.13,3.64,5.68,9.98,16.12,26.45,41.44,70.73,125.53,234.40 | |
2002,1.35,0.16,0.18,0.58,0.72,0.81,0.85,1.08,1.45,2.25,3.48,5.88,9.25,15.36,25.43,41.84,68.58,124.70,236.02 | |
2003,1.26,0.13,0.18,0.72,0.67,0.73,0.87,1.06,1.47,2.27,3.59,5.51,8.93,14.82,24.69,39.74,68.61,120.74,229.86 | |
2004,1.36,0.11,0.17,0.65,0.67,0.69,0.72,1.09,1.36,2.30,3.45,5.19,8.73,14.41,23.78,39.28,68.87,124.05,232.43 | |
2005,1.25,0.15,0.16,0.66,0.74,0.65,0.78,1.03,1.50,2.16,3.23,5.18,8.23,12.97,21.28,35.79,64.97,109.58,214.40 | |
2006,1.25,0.12,0.14,0.64,0.61,0.65,0.73,0.95,1.36,2.15,3.23,5.13,8.19,13.00,22.33,36.97,62.66,114.60,231.16 | |
2007,1.36,0.13,0.18,0.58,0.70,0.60,0.81,1.07,1.45,2.07,3.23,5.03,7.75,12.83,21.73,36.08,62.79,111.68,222.69 | |
2008,1.34,0.13,0.17,0.62,0.72,0.64,0.69,1.03,1.35,1.89,2.97,5.22,7.86,12.76,21.17,36.18,63.49,113.76,224.52 | |
2009,1.24,0.11,0.18,0.58,0.68,0.63,0.84,0.93,1.39,2.04,3.29,4.49,7.51,12.39,20.53,33.91,61.21,109.99,222.50 | |
2010,1.24,0.06,0.14,0.53,0.63,0.55,0.65,0.93,1.37,2.11,3.04,4.64,6.99,11.68,18.98,32.23,59.59,105.67,210.76 | |
2011,1.09,0.06,0.14,0.55,0.72,0.64,0.76,0.90,1.39,1.91,2.89,4.75,7.18,12.03,19.13,33.33,59.87,112.03,225.83 | |
2012,1.01,0.11,0.15,0.55,0.61,0.55,0.64,0.82,1.32,2.11,3.05,4.26,6.82,11.25,18.74,32.25,58.77,111.38,224.15 | |
2013,0.99,0.08,0.10,0.49,0.54,0.51,0.58,0.87,1.26,1.99,3.09,4.41,6.81,10.62,18.18,31.46,56.03,107.22,206.35 | |
2014,1.24,0.13,0.10,0.38,0.48,0.51,0.59,0.83,1.23,1.87,3.06,4.48,6.80,10.69,17.84,31.65,59.02,107.49,221.73 | |
2015,1.00,0.10,0.12,0.46,0.53,0.53,0.61,0.75,1.18,1.96,2.91,4.33,6.63,10.74,18.33,31.27,58.31,105.40,220.90 | |
2016,0.83,0.11,0.11,0.39,0.49,0.55,0.64,0.76,1.26,1.83,2.98,4.56,6.53,10.38,16.61,28.99,55.25,102.72,210.68 | |
2017,0.90,0.09,0.11,0.41,0.60,0.61,0.67,0.89,1.16,1.90,2.94,4.37,6.91,10.53,17.49,30.96,57.41,108.74,216.10 | |
2018,0.90,0.09,0.14,0.44,0.56,0.56,0.67,0.83,1.22,1.73,2.92,4.58,6.75,10.20,16.71,29.33,55.74,103.81,214.78 | |
2019,1.07,0.08,0.17,0.41,0.60,0.56,0.73,0.83,1.21,1.95,3.07,4.45,6.49,10.27,16.69,29.17,53.51,107.54,215.10 | |
2020,0.86,0.07,0.14,0.40,0.50,0.53,0.54,0.77,1.15,1.80,2.81,4.27,6.22,9.75,15.39,27.47,49.80,95.40,194.56 | |
2021,1.05,0.08,0.13,0.41,0.53,0.52,0.63,0.84,1.24,1.69,2.92,4.31,6.45,9.86,15.93,27.77,51.26,100.22,207.38 | |
2022,0.82,0.07,0.11,0.34,0.55,0.61,0.66,0.83,1.18,1.94,2.97,4.73,7.07,10.55,16.74,30.04,54.69,107.50,234.89 | |
"Table information:" | |
"Units:" | |
"/ 1000, Magnitude = Units" | |
"" | |
"Footnotes:" | |
"Rates from 1991 onward are based on the resident population concept. Before 1991, rates are based on the de facto population concept. Vitals data (births, deaths and marriages) is based on date of registration (not date of occurrence)." | |
"Deaths per 1,000 mean estimated population in each age group." | |
" " | |
"Symbols:" | |
".. figure not available" | |
"C: Confidential" | |
"E: Early Estimate" | |
"P: Provisional" | |
"R: Revised" | |
"S: Suppressed" | |
"" | |
"Status flags are not displayed" | |
"" | |
"Table reference: " | |
"DMM001AA" | |
"" | |
"Last updated:" | |
"16 November 2023 10:45am" | |
"" | |
"Source: Statistics New Zealand" | |
"Contact: Information Centre" | |
"Telephone: 0508 525 525" | |
"Email:[email protected]" | |
"" | |
"" | |
"" |
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
# Death rates by age | |
# https://infoshare.stats.govt.nz : Death Rates DMM : Age-specific death rates by sex, December years (total population) (Annual-Dec) | |
# Total population, All Ages, All Years | |
# Saved as AgeRates.csv | |
library(dplyr) | |
library(tidyr) | |
AR <- read.csv("AgeRates.csv", skip=2) |> | |
gather(key="Age", value="per1k", 2:20) |> | |
mutate(low_n = as.numeric(gsub("[^0123456789]","", substr(Age,2,3))), | |
Year = as.numeric(X.)) |> | |
filter(!.is.na(per1k)) | |
#Standard Population from https://seer.cancer.gov/stdpopulations/stdpop.singleages.html | |
# US 2000 single years to 99, 100+ | |
# to make 5 years to 89 then 90+ as an exact match to the data | |
library("rvest") | |
url <- "https://seer.cancer.gov/stdpopulations/stdpop.singleages.html" | |
population <- read_html(url) |> | |
html_table() | |
StndPops <- population[[1]] | |
US <- StndPops[2:102,1:2] | |
US_clean <- US |> | |
mutate(age_n = floor(as.numeric(gsub("[^0123456789]","", US$Age))/5), | |
age_n = ifelse(age_n > 18,18,age_n), | |
pop_n = as.numeric(gsub(",","", `2000 U.S. Standard Population (Census P25-1130)`))) |> | |
summarise(.by=age_n, | |
Pop = sum(pop_n)) |> | |
mutate(low_n = age_n*5) |> | |
select(low_n, Pop) | |
combo <- AR |> inner_join(US_clean, by="low_n") |> | |
summarise(.by=Year, Standard_Deaths = sum(Pop * per1k / 1000)) | |
precovid <- combo[combo$Year < 2020,] | |
plot(precovid$Year, precovid$Standard_Deaths) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment