-
Notifications
You must be signed in to change notification settings - Fork 1
/
Live Births.R
37 lines (25 loc) · 1.4 KB
/
Live Births.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
28
29
30
31
32
33
34
# ScotPHO indicators: Live births
# Part 1 - Format raw data ready for analysis functions
# Part 2 - calling the analysis functions
###############################################.
## Packages/Filepaths/Functions ----
###############################################.
source("1.indicator_analysis.R") #Normal indicator functions
source("2.deprivation_analysis.R") # deprivation function
###############################################.
## Part 1 - Format raw data ready for analysis functions ----
###############################################.
live_births <- read_excel(paste0(data_folder,
"Received Data/Births 2002-2021 datazone_2011.xlsx")) %>%
setNames(tolower(names(.))) %>%
rename(year = "registration year", datazone = datazone_2011) %>%
group_by(year, datazone) %>%
summarise(numerator = sum(count, na.rm = TRUE), .groups = "drop")
saveRDS(live_births, file=paste0(data_folder, 'Prepared Data/live_births_raw.rds'))
###############################################.
## Part 2 - Run analysis functions ----
###############################################.
analyze_first(filename = "live_births", geography = "datazone11", measure = "crude",
yearstart = 2002, yearend = 2021, time_agg = 1, pop ='DZ11_pop_allages')
analyze_second(filename = "live_births", measure = "crude", time_agg = 1, crude_rate=1000,
ind_id = 20008, year_type = "calendar")