-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathons_amenable.R
27 lines (16 loc) · 940 Bytes
/
ons_amenable.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## extract ONS amenable mortality data
library(tidyverse)
library(openxlsx)
library(readxl)
url <- "https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/healthandsocialcare/causesofdeath/datasets/deathratesandyearsoflifelostforcausesconsideredavoidableamenableandpreventableenglandandwalesandenglishregions/2015/referencetable1final1.xls"
ons <- downloader::download(url, "ons_data.xls")
amenable_cause_table <- read_excel("ons_data.xls", sheet = "Definition",range = "B6:F73" )
ons_data1 <- read_excel("ons_data.xls", sheet = "Amenable",range = "A12:P26" )
amenable_rates <- ons_data1 %>%
mutate(cause1 = lag(Cause)) %>%
mutate(Cause = ifelse(is.na(Cause), cause1, Cause)) %>%
janitor::clean_names()
preventable_rates <- read_excel("ons_data.xls", sheet = "Preventable",range = "A12:P28" ) %>%
mutate(cause1 = lag(Cause)) %>%
mutate(Cause = ifelse(is.na(Cause), cause1, Cause)) %>%
janitor::clean_names()