# Load environment file source(here::here("setup_environment.R")) # Read in SMR data, filtered on latest period/reported hospitals smr_data <- read_csv(paste0(data_folder, pub_day, "/output/", pub_day, "_SMR-data.csv")) %>% filter(period == 3 & location %in% c(hosp_filter, scot_filter)) %>% mutate(st_err = round_half_up(sqrt(1/round_half_up(pred, 8)), 8), z = if_else(location_type == "hospital", round_half_up(((round_half_up(smr, 8) - 1)/round_half_up(st_err,8)), 8), 0)) %>% mutate( z_max = max(z), z_min = min(z), z_flag = case_when(z == z_max ~ 1, z == z_min ~ -1, TRUE ~ 0), z = if_else(z == z_max | z == z_min, 0, z), z_max = max(z), z_min = min(z), z = case_when(z_flag == 1 ~ z_max, z_flag == -1 ~ z_min, TRUE ~ z), z_flag = if_else(z != 0, 1, 0), w_score = round_half_up(sqrt(sum(round_half_up(z * z, 8))/sum(z_flag)),8)) %>% # Calculate funnel limits for funnel plot mutate(uwl = 1 + 1.96 * round_half_up(st_err * w_score,8), ucl = 1 + 3.09 * round_half_up(st_err * w_score,8), lwl = 1 - 1.96 * round_half_up(st_err * w_score,8), lcl = 1 - 3.09 * round_half_up(st_err * w_score,8)) %>% # Create flag for where hospital sits on funnel plot mutate(flag = case_when(smr > ucl ~ "2", smr > uwl & smr <= ucl ~ "1", smr < lwl & smr >= lcl ~ "1", TRUE ~ "0")) #Create contact information #contact1 <- "Isabella Tortora Brayda | Senior Information Analyst | <phs.QualityIndicators@phs.scot>" #contact2 <- "Paul Ogharanduku | Senior Information Analyst | <phs.QualityIndicators@phs.scot>" contact1 <- "Charlotte Hill | Information Analyst | <phs.QualityIndicators@phs.scot>" contact2 <- "Echo Lian | Senior Information Analyst | <phs.QualityIndicators@phs.scot>"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.