Skip to content

Commit

Permalink
Added totals waits to Wales rtt dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
jennajt committed Jan 25, 2024
1 parent 7f1fb62 commit 6e7b28e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions data-raw/wales-rtt.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ wales_waits <-
# Extract number from the waiting code
mutate(Weekswaiting_Code = str_extract(Weekswaiting_Code, "^[0-9]+") |> as.integer()) |>
# Keep only waits >= 18 weeks
filter(Weekswaiting_Code >= 18) |>
# filter(Weekswaiting_Code >= 18) |>
mutate(Data = as.integer(Data))

wales_waits_18 <-
wales_waits |>
filter(Weekswaiting_Code >= 18) |>
group_by(lhb22_code, lhb22_name, date, pathway_stage) |>
summarise(waits_over_18_weeks = sum(Data, na.rm = TRUE)) |>
ungroup()
Expand All @@ -37,6 +38,12 @@ wales_waits_53 <-
summarise(waits_over_53_weeks = sum(Data, na.rm = TRUE)) |>
ungroup()

wales_waits_total <- # All waits
wales_waits |>
group_by(lhb22_code, lhb22_name, date, pathway_stage) |>
summarise(total_waits = sum(Data, na.rm = TRUE)) |>
ungroup()

# Make dataframe for joining
wales_rtt_lhb <-
wales_waits |>
Expand All @@ -45,7 +52,8 @@ wales_rtt_lhb <-
wales_rtt_lhb <-
wales_rtt_lhb |>
left_join(wales_waits_18) |>
left_join(wales_waits_53)
left_join(wales_waits_53) |>
left_join(wales_waits_total)

# Save output to data/ folder
usethis::use_data(wales_rtt_lhb, overwrite = TRUE)
Binary file modified data/wales_rtt_lhb.rda
Binary file not shown.

0 comments on commit 6e7b28e

Please sign in to comment.