-
Notifications
You must be signed in to change notification settings - Fork 1
/
Healthy weight at birth.R
45 lines (33 loc) · 1.82 KB
/
Healthy weight at birth.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
35
36
37
38
39
40
41
42
43
# ScotPHO indicators: Healthy weight at birth
# Part 1 - Prepare basefile
# Part 2 - Run analysis functions
###############################################.
## Packages/Filepaths/Functions ----
###############################################.
source("1.indicator_analysis.R") #Normal indicator functions
source("2.deprivation_analysis.R") # deprivation function
###############################################.
## Part 1 - Prepare basefile ----
###############################################.
birthweight <- read_csv(paste0(data_folder, "Received Data/Healthy birth weight/IR2024-00001_bwt.csv")) %>%
setNames(tolower(names(.))) %>% #variables to lower case
rename(year = finyear, datazone = datazone2011, numerator = numerator_normal) %>%
mutate(year = substr(year, start=1, stop=4)) %>% # Fyear coded by year ending Mar31. Change to match profiles.
select(-numerator_low)
saveRDS(birthweight, file=paste0(data_folder, 'Prepared Data/healthy_birth_raw.rds'))
#Deprivation file
birthweight_dep <- birthweight %>% filter(year>=2014)
saveRDS(birthweight_dep, file=paste0(data_folder, 'Prepared Data/healthy_birth_depr_raw.rds'))
###############################################.
## Part 2 - Run analysis functions ----
###############################################.
#CYP profile
analyze_first(filename = "healthy_birth", geography = "datazone11", measure = "percent",
yearstart = 2002, yearend = 2022, time_agg = 3)
analyze_second(filename = "healthy_birth", measure = "percent", time_agg = 3,
ind_id = 21105, year_type = "financial")
#Deprivation analysis function
#Deprivation function not applicable for this indicator
#analyze_deprivation(filename="healthy_birth_depr", measure="percent", time_agg=3,
#yearstart= 2014, yearend=2022, year_type = "financial", ind_id = 21105)
##END