Contents

Country: Ghana
Neglected Tropical Disease: Buruli Ulcer

Content
Chart 1 - Data table disaplaying metrcis split into quintiles.
Chart 2 - Heatmap displaying metrics for each District, ordered by Region. Chart 3 - Histograms displaying counts of raw data with breakpoints for seporation into quintiles for each metric and all 260 districts.
Chart 4 - Map displaying metrics for each distrcit colour coded.
Chart 5 - Data table disaplaying metrcis with raw data values for each District.

Chart 1 - Quintile Data Table

Chart 2 - Heatmap

Chart 3 - Histogram Plots

Chart 4 - Map

Chart 5 - Raw Data Table

---
title: "Skin NTD"
author: "William Jones-Warner"
output:
  flexdashboard::flex_dashboard:
    storyboard: true
    social: menu
    source: embed
    css = <style type="text/css"> .sidebar { overflow: auto; } </style>
---

### Contents

- *Slides Contained in Report*

Country: Ghana  
Neglected Tropical Disease: Buruli Ulcer  

Content  
Chart 1 - Data table disaplaying metrcis split into quintiles.  
Chart 2 - Heatmap displaying metrics for each District, ordered by Region.
Chart 3 - Histograms displaying counts of raw data with breakpoints for seporation into quintiles for each metric and all 260 districts.  
Chart 4 - Map displaying metrics for each distrcit colour coded.  
Chart 5 - Data table disaplaying metrcis with raw data values for each District.


```{r Packages, include=FALSE}
source("scripts/ipak.R")

# List of packages
packages <- c("lubridate", "statar", "flexdashboard",  "cowplot", "knitr", "stringr", "readxl", "sf",
              "dplyr", "RColorBrewer", "ggplot2", "png", "leaflet", "plotly", "hms", "mapview", "tmap", "kableExtra", "stargazer",
              "DT", "pandoc", "widgetframe", "gridExtra", "heatmaply", "dendextend")
ipak(packages)

df <- read.csv("data/tables/Coded_Variables.csv")

nrow(df)

```

### Chart 1 - Quintile Data Table

- *Chart 1: Data Table displaying Quintiles*

```{r Data Table2, echo=FALSE}


colnames(df) <- c("OBJECTID", "REGION", "DISTRICT", "BU Presence", "BU Quintile", "1km from Road", "5km from HCC",
                  "Pop per HCC", "Urban Pop", "UrbanLand", "Improved Housing",
                  "Wealth Index", "U5M", "MVC", "DTP", "Pop Den", "Mobile Phone")

datatable(df, filter = "top", options = list(
  pageLength = 260,
  searching = TRUE,
  order = list()  # This disables initial sorting
))
```


### Chart 2 - Heatmap


- *Chart 2: Heatmap*

```{r HeatMap Setup, include=FALSE}


dfq <- df[, colnames(df) %in% c(
  "REGION", "DISTRICT", "BU Quintile", "1km from Road", "5km from HCC",
  "Pop per HCC", "Urban Pop", "UrbanLand", "Improved Housing",
  "Wealth Index", "U5M", "MVC", "DTP", "Pop Den", "Mobile Phone"
)]

dfq <- dfq %>%
  mutate(REGION_DISTRICT = paste(REGION, DISTRICT,  sep = " - ")) %>%
  select(REGION_DISTRICT, everything()) %>%
  select(-DISTRICT, -REGION)

row_names <- dfq[, 1]

# Set the row names of the dataframe
rownames(dfq) <- row_names

# Remove the first column from the dataframe
dfq <- dfq[, -1]

ordered_data <- dfq[order(rownames(dfq)), ]
ordered_data_m <- as.matrix(ordered_data)

heatmap <- plot_ly(x = colnames(ordered_data_m), y = rownames(ordered_data_m),
                   z = ordered_data_m, type = "heatmap",
                   colorscale = list(c(0, 1), c("white", "coral")))


```

```{r HeatMap, echo=FALSE}

heatmap
```

### Chart 3 - Histogram Plots 

```{r Histo, fig.show="hold", out.width="33%", echo=FALSE}

df_raw <- read.csv("data/tables/Consolidated_Working_Sheet_20230807.csv")

ggplot(data = df_raw, aes(x = X.URBAN.POP)) +
  geom_histogram(binwidth = (max(df_raw$X.URBAN.POP) - min(df_raw$X.URBAN.POP)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.2, 0.4, 0.6, 0.8), linetype = "dashed", color = "red") +
  labs(title = "Histogram of Districts Urban Poopulation %",
       x = "% of Distrcit Population living in an Urban Area",
       y = "Frequency")

ggplot(data = df_raw, aes(x = X5kmHCC_PER)) +
  geom_histogram(binwidth = (max(df_raw$X5kmHCC_PER) - min(df_raw$X5kmHCC_PER)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.0001, 0.2, 0.4, 0.6), linetype = "dashed", color = "red") +
  labs(title = "Histogram of the % of a District that lives further than 5km from a HCC",
       x = "% of Distrcit",
       y = "Frequency")

ggplot(data = df_raw, aes(x = Further1km..round)) +
  geom_histogram(binwidth = (max(df_raw$Further1km._round) - min(df_raw$Further1km._round)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.2, 0.4, 0.6, 0.8), linetype = "dashed", color = "red") +
  labs(title = "Histogram of the % of a District that lives further than 1km from a Road",
       x = "% of Distrcit",
       y = "Frequency")

ggplot(data = df_raw, aes(x = UrbanLand.Pixel..)) +
  geom_histogram(binwidth = (max(df_raw$UrbanLand.Pixel..) - min(df_raw$UrbanLand.Pixel..)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.2, 0.4, 0.6, 0.8), linetype = "dashed", color = "red") +
  labs(title = "Histogram of the % of a District that is urbanised",
       x = "% of Distrcit",
       y = "Frequency")

ggplot(data = df_raw, aes(x = TIFF_POPDEN)) +
  geom_histogram(binwidth = (max(df_raw$TIFF_POPDEN) - min(df_raw$TIFF_POPDEN)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(64.2,	111,	185.9,	437.6), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District Population Density (PP/SQKM)",
       x = "Population Density of Distrcit",
       y = "Frequency")

ggplot(data = df_raw, aes(x = mobile_per)) +
  geom_histogram(binwidth = (max(df_raw$mobile_per) - min(df_raw$mobile_per)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.82,	0.88,	0.92,	0.96), linetype = "dashed", color = "red") +
  labs(title = "Histogram of % Mobile Phone Ownership",
       x = "% of Distrcit",
       y = "Frequency")


ggplot(data = df_raw, aes(x =Mean.DTP.Coverage)) +
  geom_histogram(binwidth = (max(df_raw$Mean.DTP.Coverage) - min(df_raw$Mean.DTP.Coverage)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.88,	0.9,	0.92,	0.93), linetype = "dashed", color = "red") +
  labs(title = "Histogram of DTP Coverage",
       x = "% Coverage of of Distrcit",
       y = "Frequency")

ggplot(data = df_raw, aes(x =U5M_mean)) +
  geom_histogram(binwidth = (max(df_raw$U5M_mean) - min(df_raw$U5M_mean)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.09,	0.1,	0.11,	0.13), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District's Under 5 Mortlity",
       x = "District Probability",
       y = "Frequency")


ggplot(data = df_raw, aes(x =MVC_mean)) +
  geom_histogram(binwidth = (max(df_raw$MVC_mean) - min(df_raw$MVC_mean)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(88.93,	90.37,	91.81,	92.82), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District's MCV Coverage (%)",
       x = "District %",
       y = "Frequency")

ggplot(data = df_raw, aes(x = RWI_UR_MODE)) +
  geom_histogram(binwidth = (max(df_raw$RWI_UR_MODE) - min(df_raw$RWI_UR_MODE)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(1,	2,	3,	4), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District's Modal Realtive Wealth Index",
       x = "District RWI",
       y = "Frequency")

ggplot(data = df_raw, aes(x = BU_mean)) +
  geom_histogram(binwidth = (max(df_raw$BU_mean) - min(df_raw$BU_mean)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.005, 0.25,	0.5,	0.75), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District's Buruli Ulcer (BU) Coverage",
       x = "BU Occurances",
       y = "Frequency")

ggplot(data = df_raw, aes(x = IH2_mean)) +
  geom_histogram(binwidth = (max(df_raw$IH2_mean) - min(df_raw$IH2_mean)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(0.1, 0.2,	0.3,	0.4), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District's Prevalence of improved Housing",
       x = "Prevalence",
       y = "Frequency")

ggplot(data = df_raw, aes(x = POP_PER_HCC)) +
  geom_histogram(binwidth = (max(df_raw$POP_PER_HCC) - min(df_raw$POP_PER_HCC)) / 100, fill = "skyblue", color = "black") +
  geom_vline(xintercept = c(10000, 15000, 20000, 25000), linetype = "dashed", color = "red") +
  labs(title = "Histogram of District's Population per HCC",
       x = "PP Per HCC",
       y = "Frequency")
```

### Chart 4 - Map

- *Chart 4: Map displaying Quintiles*

```{r Map Setup, include=FALSE, cache=TRUE, echo=FALSE}

data <- st_read("data/shapeFiles/Ghana_BU.shp")
adm1 <- st_read("data/shapeFiles/adm1.shp")

quantiles <- (0:5) / 5  

# Define your custom bin edges
bin_edges <- c(0, 10000, 15000, 25000, 30000, Inf)
bin_edgesPOP.DEN <- c(0, 64.6, 111.5, 194.2, Inf)
bin_edgesU5M <- c(0, 0.09, 0.1, 0.13, Inf)
bin_edgesDPT_Cvr <- c(round(quantile(data$DPT_Cvr[which(data$DPT_Cvr >0)], quantiles, names = F), digits = 4))
bin_edgesX1kmRoad<- c(0, 0.2, 0.4, 0.6, 0.8, 1.0)
bin_edgesImproHo <- c(0, 0.0455, 0.0985, 0.1433, 0.2212, 0.44)
bin_edgesMCV_MEA <- c(84, 88.9812, 90.3702, 91.8193, 92.8286, 94.7)
bin_edgesBU <- c(0, 0.00000000000000000000000001, 0.25, 0.5, 0.75, Inf)
bin_edgesDHS_WI_ <- c(1, 2, 3, 4, 5)
bin_edgesUrbnPOP <- c(0, 0.2, 0.4, 0.6, 0.8, 1)
bin_edgesUrbnstn <- c(0, 0.2, 0.4, 0.6, 0.8, 1)
bin_edgesMoblPhn <- c(round(quantile(data$MoblPhn[which(data$MoblPhn >0)], quantiles, names = F), digits = 4))
bin_edgesFrt5HCC <- c(0, 0.0000000000001, 0.2, 0.4, 0.6, 1.0)


Total <- c("#1a9641", "#a6d96a","#ffffbf",  "#fdae61", "#d7191c", "#8B0000")
Reverse <- c("#8B0000", "#d7191c", "#fdae61", "#ffffbf", "#a6d96a", "#1a9641")

# Create color bins for the variable data$POPperHCC
palPOPperHCC <- colorBin(Total, domain = data$POPpHCC, bins = bin_edges)
palPOP.DEN <- colorBin(Total, domain = data$POP.DEN, bins = bin_edgesPOP.DEN)
palU5M <- colorBin(Total, domain = data$U5M, bins = bin_edgesU5M)
palDPT_Cvr <- colorBin(Reverse, domain = data$DPT_Cvr, bins = bin_edgesDPT_Cvr)
palX1kmRoad <- colorBin(Total, domain = data$X1kmRoad, bins = bin_edgesX1kmRoad)
palImproHo <- colorBin(Reverse, domain = data$ImproHo, bins = bin_edgesImproHo)
palMCV_MEA <- colorBin(Reverse, domain = data$MCV_MEA, bins = bin_edgesMCV_MEA)
palBU <- colorBin(Total, domain = data$BU, bins = bin_edgesBU)
palDHS_WI_ <- colorFactor(Reverse, domain = data$DHS_WI_)
palUrbnPOP <- colorBin(Total, domain = round(data$UrbnPOP, 3), bins = bin_edgesUrbnPOP)
palUrbnstn <- colorBin(Total, domain = data$Urbnstn, bins = bin_edgesUrbnstn)
palMoblPhn <- colorBin(Total, domain = data$MoblPhn, bins = bin_edgesMoblPhn)
palFrt5HCC <- colorBin(Total, domain = data$Frt5HCC, bins = bin_edgesFrt5HCC)


## define labels

POPperHCClabels <- sprintf(
  "<strong>%s</strong><br/>%g people / HCC",
  data$DISTRIC, round(data$POPpHCC, 0)
) %>% lapply(htmltools::HTML)

POP.DENlabels <- sprintf(
  "<strong>%s</strong><br/>%g people / km<sup>2</sup>",
  data$DISTRIC, round(data$POP.DEN, 0)
) %>% lapply(htmltools::HTML)

U5Mlabels <- sprintf(
  "<strong>%s</strong><br/>%g Probility of Death",
  data$DISTRIC, round(data$U5M, 4)
) %>% lapply(htmltools::HTML)

DPT_Cvrlabels <- sprintf(
  "<strong>%s</strong><br/>%g DPT Coverage",
  data$DISTRIC, round(data$DPT_Cvr, 3)
) %>% lapply(htmltools::HTML)

X1kmRoadlabels <- sprintf(
  "<strong>%s</strong><br/>%g Further than 1km From Road",
  data$DISTRIC, round(data$X1kmRoad, 1)
) %>% lapply(htmltools::HTML)

ImproHolabels <- sprintf(
  "<strong>%s</strong><br/>%g Improved Housing Prevalence",
  data$DISTRIC, round(data$ImproHo, 3)
) %>% lapply(htmltools::HTML)

MCV_MEAlabels <- sprintf(
  "<strong>%s</strong><br/>%g MCV Coverage",
  data$DISTRIC, round(data$MCV_MEA, 4)
) %>% lapply(htmltools::HTML)

BUlabels <- sprintf(
  "<strong>%s</strong><br/>%g Predicted BU Occurance",
  data$DISTRIC, round(data$BU, 2)
) %>% lapply(htmltools::HTML) 

DHS_WI_labels <- sprintf(
  "<strong>%s</strong><br/>%g Wealth Index Quintile",
  data$DISTRIC, round(data$DHS_WI_, 2)
) %>% lapply(htmltools::HTML) 

UrbnPOPlabels <- sprintf(
  "<strong>%s</strong><br/>%g Urban Population",
  data$DISTRIC, round(data$UrbnPOP, 3)
) %>% lapply(htmltools::HTML) 

Urbnstnlabels <- sprintf(
  "<strong>%s</strong><br/>%g Urbanisation",
  data$DISTRIC, round(data$Urbnstn, 2)
) %>% lapply(htmltools::HTML) 

Frt5HCClabels <- sprintf(
  "<strong>%s</strong><br/>%g Population Living within 5km of a HCC",
  data$DISTRIC, round(data$Frt5HCC, 2)
) %>% lapply(htmltools::HTML) 

MoblPhnlabels <- sprintf(
  "<strong>%s</strong><br/>%g Mobile Phone Ownership",
  data$DISTRIC, round(data$MoblPhn, 2)
) %>% lapply(htmltools::HTML) 

map <- leaflet(data) %>%
    ## add Pop per HCC  
  

  addPolygons(fillColor = ~palPOPperHCC(POPpHCC), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Population Per HCC",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = POPperHCClabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palPOP.DEN(POP.DEN), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Population Density",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = POP.DENlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palU5M(U5M), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Under 5 Mortality",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = U5Mlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palDPT_Cvr(DPT_Cvr), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "DPT Coverage",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = DPT_Cvrlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palX1kmRoad(X1kmRoad), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Further 1km Road",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = X1kmRoadlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palImproHo(ImproHo), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Improved Housing",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = ImproHolabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palMCV_MEA(MCV_MEA), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "MCV Coverage",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = MCV_MEAlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palBU(BU), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "BU",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = BUlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palDHS_WI_(DHS_WI_), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Wealth Index",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = DHS_WI_labels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palUrbnPOP(round(UrbnPOP, 3)), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "UrbanPOP",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = UrbnPOPlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palUrbnstn(Urbnstn), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Urbanisation",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = Urbnstnlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palMoblPhn(MoblPhn), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "MobilePhone",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = MoblPhnlabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(fillColor = ~palFrt5HCC(Frt5HCC), 
              weight = 1,
              opacity = 1,
              color = "black",
              group = "Further5kmHCC",
              dashArray = "",
              fillOpacity = 2, 
              highlight = highlightOptions(
                weight = 5,
                color = "#666",
                dashArray = "",
                fillOpacity = 0.7,
                bringToFront = FALSE),
              label = Frt5HCClabels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addPolygons(data = adm1,
              weight = 2,
              opacity = 1,
              color = "black",
              group = "adm1",
              dashArray = "",
              fillOpacity = 0) %>%
  
  # Layers control
  addLayersControl(
    
    baseGroups = c("Open Street Map", "ESRI World Imagery"),
    overlayGroups = c("adm1", "Population Per HCC", "Population Density", "Under 5 Mortality", "DPT Coverage", "Further 1km Road", "Improved Housing", "MCV Coverage", "BU", "Wealth Index", "UrbanPOP", "Urbanisation", "MobilePhone", "Further5kmHCC"),
    
    options = layersControlOptions(collapsed = FALSE)) %>% 
  
  addLegend(pal = palPOPperHCC, values = ~POPpHCC, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Population Per HCC")%>% 
  
  addLegend(pal = palPOP.DEN, values = ~POP.DEN, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Population Density")%>% 
  
  addLegend(pal = palU5M, values = ~U5M, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Under 5 Mortality")%>% 
  
  addLegend(pal = palDPT_Cvr, values = ~DPT_Cvr, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "DPT Coverage")%>% 
  
  addLegend(pal = palX1kmRoad, values = ~X1kmRoad, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Further 1km Road")%>% 
  
  addLegend(pal = palImproHo, values = ~ImproHo, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Improved Housing")%>% 
  
  addLegend(pal = palMCV_MEA, values = ~MCV_MEA, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "MCV Coverage")%>% 
  
  addLegend(pal = palBU, values = ~BU, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "BU")%>% 
  
  addLegend(pal = palDHS_WI_, values = ~DHS_WI_, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Wealth Index")%>% 
  
  addLegend(pal = palUrbnPOP, values = ~round(UrbnPOP, 3), opacity = 0.7, title = NULL,
            position = "bottomleft", group = "UrbanPOP")%>% 
  
  addLegend(pal = palUrbnstn, values = ~Urbnstn, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Urbanisation")%>% 
 
  addLegend(pal = palMoblPhn, values = ~MoblPhn, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "MobilePhone")%>% 
  
  addLegend(pal = palFrt5HCC, values = ~Frt5HCC, opacity = 0.7, title = NULL,
            position = "bottomleft", group = "Further5kmHCC")%>% 
  
  hideGroup(c("Population Per HCC", "Population Density", "Under 5 Mortality", "DPT Coverage", "Further 1km Road", "Improved Housing", "MCV Coverage", "BU", "Wealth Index", "UrbanPOP", "Urbanisation", "MobilePhone", "Further5kmHCC"))
```

```{r Map, echo=FALSE}

widgetframe::frameWidget(map, width = "100%")

```

### Chart 5 - Raw Data Table


- *Chart 5: Raw Data Table*

```{r Data Table raw, echo=FALSE}

df_raw1 <- df_raw

column_mapping <- c("OBJECTID" = "OBJECTID",
                    "REGION" = "REGION",
                    "DISTRICT" = "DISTRICT",
                    "X.URBAN.POP" = "Urban Pop",
                    "Further1km._round" = "1km from Road",
                    "UrbanLand.Pixel.." = "Urban Land.",
                    "Mean.DTP.Coverage" = "DTP",
                    "U5M_mean" = "U5M",
                    "BU_mean" = "BU",
                    "RWI_UR_MODE" = "Wealth Index",
                    "MVC_mean" = "MVC",
                    "mobile_per" = "Mobile Phone",
                    "X5kmHCC_PER" = "5km from HCC",
                    "TIFF_POPDEN" = "Pop Den",
                    "POP_PER_HCC" = "Pop Per HCC",
                    "IH2_mean" = "Improved Housing")

# Apply the column name changes to the data frame
colnames(df_raw1) <- column_mapping

datatable(df_raw1, filter = "top", options = list(
  pageLength = 260,
  searching = TRUE,
  order = list()  # This disables initial sorting
))

```