Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Demographics/1. Demographics - Population.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@
ungroup()

# compute age bands
pop_raw_data$"Pop0_4" <- rowSums(subset(pop_raw_data, select = age0:age4))

Check warning on line 77 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=77,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data$"Pop5_17" <- rowSums(subset(pop_raw_data, select = age5:age17))

Check warning on line 78 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=78,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data$"Pop18_44" <- rowSums(subset(pop_raw_data, select = age18:age44))

Check warning on line 79 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=79,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data$"Pop45_64" <- rowSums(subset(pop_raw_data, select = age45:age64))

Check warning on line 80 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=80,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data$"Pop65_74" <- rowSums(subset(pop_raw_data, select = age65:age74))

Check warning on line 81 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=81,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data$"Pop75_84" <- rowSums(subset(pop_raw_data, select = age75:age84))

Check warning on line 82 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=82,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data$"Pop85Plus" <- rowSums(subset(

Check warning on line 83 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=83,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data,
select = age85:age90plus
))
pop_raw_data$"Pop65Plus" <- rowSums(subset(

Check warning on line 87 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=87,col=14,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
pop_raw_data,
select = age65:age90plus
))
Expand All @@ -108,8 +108,8 @@


# Aggregate and add partnership + Scotland totals
pops <- pops %>%

Check warning on line 111 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=111,col=14,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
group_by(year, sex, hscp2019name, hscp_locality) %>%

Check warning on line 112 in Demographics/1. Demographics - Population.R

View workflow job for this annotation

GitHub Actions / Lint modified files

file=Demographics/1. Demographics - Population.R,line=112,col=52,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
summarise(across(everything(), sum)) %>%
ungroup() %>%
# Add a partnership total
Expand Down Expand Up @@ -501,7 +501,7 @@
# Determine other localities based on LOCALITY object
other_locs <- lookup %>%
select(hscp_locality, hscp2019name) %>%
filter(hscp2019name == HSCP & hscp_locality != LOCALITY) %>%
filter(hscp2019name == HSCP, hscp_locality != LOCALITY) %>%
arrange(hscp_locality)

# Find number of locs per partnership
Expand Down
2 changes: 1 addition & 1 deletion Demographics/2. Demographics - SIMD.R
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ HSCP <- as.character(filter(lookup, hscp_locality == LOCALITY)$hscp2019name)
# Determine other localities based on LOCALITY object
other_locs <- lookup %>%
select(hscp_locality, hscp2019name) %>%
filter(hscp2019name == HSCP & hscp_locality != LOCALITY) %>%
filter(hscp2019name == HSCP, hscp_locality != LOCALITY) %>%
arrange(hscp_locality)

# Find number of locs per partnership
Expand Down
2 changes: 1 addition & 1 deletion Households/Households Code.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ HSCP <- as.character(filter(lookup2, hscp_locality == LOCALITY)$hscp2019name)
# Determine other localities based on LOCALITY object
other_locs <- lookup2 %>%
select(hscp_locality, hscp2019name) %>%
filter(hscp2019name == HSCP & hscp_locality != LOCALITY) %>%
filter(hscp2019name == HSCP, hscp_locality != LOCALITY) %>%
arrange(hscp_locality)

# Find number of locs per partnership
Expand Down
57 changes: 30 additions & 27 deletions Lifestyle & Risk Factors/2. Lifestyle & Risk Factors Outputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ HB <- as.character(filter(lookup, hscp_locality == LOCALITY)$hb2019name)
# Determine other localities based on LOCALITY object
other_locs <- lookup %>%
select(hscp_locality, hscp2019name) %>%
filter(hscp2019name == HSCP & hscp_locality != LOCALITY) %>%
filter(hscp2019name == HSCP, hscp_locality != LOCALITY) %>%
arrange(hscp_locality)

# Find number of locs per partnership
Expand Down Expand Up @@ -229,15 +229,15 @@ alcohol_hosp_bar

alcohol_hosp_latest <- filter(
alcohol_hosp,
year == max(alcohol_hosp$year) &
(area_name == LOCALITY & area_type == "Locality")
)$measure
year == max(alcohol_hosp[["year"]]),
(area_name == LOCALITY & area_type == "Locality")
)[["measure"]]

alcohol_hosp_earliest <- filter(
alcohol_hosp,
(year == min(alcohol_hosp$year)) &
(area_name == LOCALITY & area_type == "Locality")
)$measure
(year == min(alcohol_hosp[["year"]])),
(area_name == LOCALITY & area_type == "Locality")
)[["measure"]]

alcohol_hosp_change <- abs(
(alcohol_hosp_latest - alcohol_hosp_earliest) / alcohol_hosp_earliest * 100
Expand All @@ -250,8 +250,9 @@ alcohol_hosp_change_word <- if_else(

scot_alcohol_hosp <- filter(
alcohol_hosp,
year == max(alcohol_hosp$year) & area_name == "Scotland"
)$measure
year == max(alcohol_hosp[["year"]]),
area_name == "Scotland"
)[["measure"]]

alcohol_hosp_diff_scot <- if_else(
alcohol_hosp_latest > scot_alcohol_hosp,
Expand Down Expand Up @@ -300,14 +301,14 @@ alcohol_deaths_bar

alcohol_deaths_latest <- filter(
alcohol_deaths,
year == max(alcohol_deaths$year) &
(area_name == LOCALITY & area_type == "Locality")
year == max(alcohol_deaths$year),
(area_name == LOCALITY & area_type == "Locality")
)$measure

alcohol_deaths_earliest <- filter(
alcohol_deaths,
(year == min(alcohol_deaths$year)) &
(area_name == LOCALITY & area_type == "Locality")
(year == min(alcohol_deaths$year)),
(area_name == LOCALITY & area_type == "Locality")
)$measure

alcohol_deaths_change <- abs(
Expand All @@ -323,7 +324,8 @@ alcohol_deaths_change_word <- if_else(

scot_alcohol_deaths <- filter(
alcohol_deaths,
year == max(alcohol_deaths$year) & area_name == "Scotland"
year == max(alcohol_deaths$year),
area_name == "Scotland"
)$measure

alcohol_deaths_diff_scot <- if_else(
Expand Down Expand Up @@ -373,14 +375,14 @@ bowel_screening_bar

bowel_screening_latest <- filter(
bowel_screening,
year == max(bowel_screening$year) &
(area_name == LOCALITY & area_type == "Locality")
year == max(bowel_screening$year),
(area_name == LOCALITY & area_type == "Locality")
)$measure

bowel_screening_earliest <- filter(
bowel_screening,
(year == min(bowel_screening$year)) &
(area_name == LOCALITY & area_type == "Locality")
(year == min(bowel_screening$year)),
(area_name == LOCALITY & area_type == "Locality")
)$measure

bowel_screening_change <- abs(
Expand All @@ -397,7 +399,8 @@ bowel_screening_change_word <- if_else(

scot_bowel_screening <- filter(
bowel_screening,
year == max(bowel_screening$year) & area_name == "Scotland"
year == max(bowel_screening$year),
area_name == "Scotland"
)$measure

bowel_screening_diff_scot <- if_else(
Expand Down Expand Up @@ -453,35 +456,35 @@ other_locs_bowel_screening <- other_locs_summary_table(
hscp_drug_hosp <- round_half_up(
filter(
drug_hosp,
year == max(year) &
(area_name == HSCP & area_type == "HSCP")
year == max(year),
(area_name == HSCP & area_type == "HSCP")
)$measure,
1
)

hscp_alcohol_hosp <- round_half_up(
filter(
alcohol_hosp,
year == max(year) &
(area_name == HSCP & area_type == "HSCP")
year == max(year),
(area_name == HSCP & area_type == "HSCP")
)$measure,
1
)

hscp_alcohol_deaths <- round_half_up(
filter(
alcohol_deaths,
year == max(year) &
(area_name == HSCP & area_type == "HSCP")
year == max(year),
(area_name == HSCP & area_type == "HSCP")
)$measure,
1
)

hscp_bowel_screening <- round_half_up(
filter(
bowel_screening,
year == max(year) &
(area_name == HSCP & area_type == "HSCP")
year == max(year),
(area_name == HSCP & area_type == "HSCP")
)$measure,
1
)
Expand Down
2 changes: 1 addition & 1 deletion Master RMarkdown Document & Render Code/Global Script.R
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ read_in_pop_proj <- memoise(read_in_pop_proj_raw)

clean_scotpho_dat <- function(data) {
data |>
filter(area_type != "Council area" & area_type != "Intermediate zone") |>
filter(area_type != "Council area", area_type != "Intermediate zone") |>
mutate(area_name = gsub("&", "and", area_name, fixed = TRUE)) |>
mutate(
area_name = if_else(
Expand Down
37 changes: 20 additions & 17 deletions Unscheduled Care/2. Unscheduled Care outputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ HB <- as.character(filter(localities, hscp_locality == LOCALITY)$hb2019name)
# Determine other localities based on LOCALITY object
other_locs <- localities %>%
select(hscp_locality, hscp2019name) %>%
filter(hscp2019name == HSCP & hscp_locality != LOCALITY) %>%
filter(hscp2019name == HSCP, hscp_locality != LOCALITY) %>%
arrange(hscp_locality)

# Find number of locs per partnership
Expand Down Expand Up @@ -624,7 +624,8 @@ max_year_ubd <- max(bed_days_areas$financial_year)
first_fy_rate_ubd <- filter(
bed_days_areas,
financial_year == min(financial_year),
location == LOCALITY & area_type == "Locality"
location == LOCALITY,
area_type == "Locality"
)$data

latest_bed_days_loc <- bed_days_areas %>%
Expand All @@ -638,7 +639,8 @@ word_change_ubd <- word_change_calc(latest_bed_days_loc2, first_fy_rate_ubd)
# HSCP
first_fy_hscp_ubd <- filter(
bed_days_areas,
(financial_year == min(bed_days_areas$financial_year)) & (area_type == "HSCP")
(financial_year == min(bed_days_areas$financial_year)),
(area_type == "HSCP")
)$data

hscp_bed_days <- bed_days_areas %>%
Expand All @@ -654,8 +656,8 @@ hscp_change_ubd <- word_change_calc(hscp_bed_days2, first_fy_hscp_ubd)
# Scotland
first_fy_scot_ubd <- filter(
bed_days_areas,
(financial_year == min(bed_days_areas$financial_year)) &
(area_type == "Scotland")
(financial_year == min(bed_days_areas$financial_year)),
(area_type == "Scotland")
)$data

scot_bed_days <- bed_days_areas %>%
Expand Down Expand Up @@ -1954,8 +1956,8 @@ psych_hosp_time_trend <- psych_hosp %>%
psych_hosp_latest <- round_half_up(
filter(
psych_hosp,
year == max(psych_hosp$year) &
(area_name == LOCALITY & area_type == "Locality")
year == max(psych_hosp$year),
(area_name == LOCALITY & area_type == "Locality")
)$measure,
1
)
Expand All @@ -1973,13 +1975,14 @@ other_locs_psych_hosp <- psych_hosp %>%
hscp_psych_hosp <- round_half_up(
filter(
psych_hosp,
year == max(year) & (area_name == HSCP & area_type == "HSCP")
year == max(year),
(area_name == HSCP & area_type == "HSCP")
)$measure,
1
)

scot_psych_hosp <- round_half_up(
filter(psych_hosp, year == max(year) & area_name == "Scotland")$measure,
filter(psych_hosp, year == max(year), area_name == "Scotland")$measure,
1
)

Expand All @@ -1992,8 +1995,8 @@ list_years_latest <- list_years$period
loc_psych_hosp <- psych_hosp %>%
filter(period %in% list_years_latest) %>%
filter(
area_name == LOCALITY &
area_type == "Locality",
area_name == LOCALITY,
area_type == "Locality",
year == min(year) | year == max(year)
) %>%
mutate(measure2 = format(measure, big.mark = ","))
Expand All @@ -2011,8 +2014,8 @@ word_change_loc_psych <- word_change_calc(
hscp_psych_hosp <- psych_hosp %>%
filter(period %in% list_years_latest) %>%
filter(
area_name == HSCP &
area_type == "HSCP",
area_name == HSCP,
area_type == "HSCP",
year == min(year) | year == max(year)
) %>%
mutate(measure2 = format(measure, big.mark = ","))
Expand All @@ -2030,8 +2033,8 @@ word_change_hscp_psych <- word_change_calc(
hb_psych_hosp <- psych_hosp %>%
filter(period %in% list_years_latest) %>%
filter(
area_name == HB &
area_type == "Health board",
area_name == HB,
area_type == "Health board",
year == min(year) | year == max(year)
) %>%
mutate(measure2 = format(measure, big.mark = ","))
Expand All @@ -2049,8 +2052,8 @@ word_change_hb_psych <- word_change_calc(
scot_psych_hosp <- psych_hosp %>%
filter(period %in% list_years_latest) %>%
filter(
area_name == "Scotland" &
area_type == "Scotland",
area_name == "Scotland",
area_type == "Scotland",
year == min(year) | year == max(year)
) %>%
mutate(measure2 = format(measure, big.mark = ","))
Expand Down
Loading