An open API service indexing awesome lists of open source software.

https://github.com/openwashdata/basisghana

This package compiles sanitation data from established Open Defecation Free (ODF) communities across different regions in Ghana.
https://github.com/openwashdata/basisghana

defecation ghana open-data openwashdata r sanitation wash

Last synced: 4 months ago
JSON representation

This package compiles sanitation data from established Open Defecation Free (ODF) communities across different regions in Ghana.

Awesome Lists containing this project

README

          

---
output: github_document
editor_options:
chunk_output_type: console
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
message = FALSE,
warning = FALSE,
fig.retina = 2,
fig.align = 'center'
)

library(tidyverse)
library(epoxy)
library(universityrankingafrica)
```

# basisghana

[![R-CMD-check](https://github.com/openwashdata/basisghana/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/openwashdata/basisghana/actions/workflows/R-CMD-check.yaml)
[![DOI](https://zenodo.org/badge/676448371.svg)](https://zenodo.org/doi/10.5281/zenodo.10255444)

This package compiles sanitation data from established Open Defecation Free (ODF) communities across different regions in Ghana.

```{r, echo=FALSE}
library(sf)
library(rnaturalearth)
library(ggplot2)
library(tidyverse)
library(basisghana)
library(dplyr)

basisghananew <- basisghana |>
rename(district_en = "district") |>
mutate(district_en = case_when(
district_en == "Abura Asebu Kwamankes" ~ "Abura-Asebu-Kwamankese",
district_en == "Ajumako Enyan Essiam" ~ "Ajumako-Enyan-Essiam",
district_en == "Asikuma Odoben Brakwa" ~ "Asikuma-Odoben-Brakwa",
district_en == "Bawku" ~ "Bawku Municipal",
district_en == "Bunkpurugu" ~ "Bunkpurugu Nakpanduri",
district_en == "Daffiama Bussie Iss" ~ "Daffiama Bussie Issa",
district_en == "East Gonja" ~ "East Gonja Municipal",
district_en == "Garu Tempane" ~ "Garu",
district_en == "Ho" ~ "Ho Municipal",
district_en == "Hohoe" ~ "Hohoe Municipal",
district_en == "Keta" ~ "Keta Municipal",
district_en == "Kpando Municipa" ~ "Kpando Municipal",
district_en == "Lambussie Karni" ~ "Lambussie-Karni",
district_en == "Nadowli Kaleo" ~ "Nadowli-Kaleo",
district_en == "Sagnarigu" ~ "Sagnerigu",
district_en == "Tatale" ~ "Tatale Sanguli",
district_en == "West Mamprusi" ~ "West Mamprusi Municipal",
district_en == "Yendi" ~ "Yendi Municipal",
district_en == "Damongo" ~ "West Gonja",
TRUE ~ district_en
))

odf_by_district <- basisghananew |>
group_by(district_en) |>
summarize(odf_population = sum(population, na.rm = TRUE))

odf_by_district <- merge(odf_by_district, ghanapop, by = 'district_en', all = TRUE) |>
mutate(percentage = round(odf_population / total_pop * 100, 2)) |>
arrange(desc(percentage))

top_10_odf <- odf_by_district |>
top_n(10, percentage) |>
select(district_en, region_en, percentage) |>
mutate(percentage = paste0(percentage, "%")) |>
rename(
district = "district_en",
region = "region_en",
`proportion ODF population in district` = "percentage"
)

#group the regions according to how they were back in 2017 (10 regions instead of 16)
odf_by_region <- odf_by_district |>
mutate(region_en = case_when(
region_en %in% c("Bono", "Bono East", "Ahafo") ~ "Brong Ahafo",
region_en %in% c("Northern", "Savannah", "Northern East") ~ "Northern",
region_en %in% c("Volta", "Oti") ~ "Volta",
region_en %in% c("Western", "Western North") ~ "Western",
TRUE ~ as.character(region_en)
)) |>
group_by(region_en) |>
summarize(
odf_population = sum(odf_population, na.rm = TRUE),
female = sum(female_pop, na.rm = TRUE),
male = sum(male_pop, na.rm = TRUE),
total_pop = sum(total_pop, na.rm = TRUE)
) |>
mutate(percentage = round(odf_population / total_pop * 100, 2)) |>
arrange(desc(percentage)) |>
filter(!is.na(region_en)) |>
select(region_en, percentage)

ghana <- ne_states(country = "Ghana", returnclass = "sf") |>
rename(
region_en = "name"
)

ggplot() +
theme_void() +
geom_sf(data = full_join(ghana, odf_by_region, by = "region_en"), aes(fill = percentage), color = "white", lwd = 0) +
scale_fill_gradientn(name = paste("Percentage of ODF population", "\n by region (logarithmic scale)"),
trans = "log",
labels = scales::label_number(accuracy = 1),
colors = c("#2E8B57","#9DBF9E", "#FCB97D", "#A84268"),
na.value = "grey80") +
labs(title = paste("Regions with highest percentage of ODF communities", "\n in Ghana (2017)")) +
theme_minimal() +
theme(
plot.title = element_text(size = 14),
plot.margin = margin(1, 1, 1, 1, "cm")
)
```

## Installation

You can install the development version of basisghana from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("openwashdata/basisghana")
```
Alternatively, you can download the individual dataset as a CSV or XLSX
file from the table below.

```{r, echo=FALSE}

extdata_path <- "https://github.com/openwashdata/basisghana/raw/main/inst/extdata/"

read_csv("data-raw/dictionary.csv") |>
distinct(file_name) |>
mutate(file_name = str_remove(file_name, ".rda")) |>
rename(dataset = file_name) |>
mutate(
CSV = paste0("[Download CSV](", extdata_path, dataset, ".csv)"),
XLSX = paste0("[Download XLSX](", extdata_path, dataset, ".xlsx)")
) |>
knitr::kable()

```
## Project goal
The primary goal of BaSIS (Basic Sanitation Information System) within the context of implementing Community-Led Total Sanitation (CLTS) in Ghana is to combat open defecation. By collecting data on communities practicing open defecation, the project aims to shift away from previous subsidy-based approaches and focus on community engagement. BaSIS seeks to empower communities, particularly in regions like Upper West, Eastern, Northern, Volta, and Central, to abandon open defecation practices through CLTS. The objective is to break the cycle of fecal-oral contamination, reduce the spread of diseases linked to poor sanitation, and promote sustainable, community-driven solutions to improve overall hygiene and sanitation practices.

## Data

The data set includes the locations of the existing open defecation free (ODF) communities in
various districts of Ghana. It was last updated in September 2017.

The package provides access to two data sets.

```{r, echo = TRUE}
library(basisghana)
```

The `basisghana` data set has `r ncol(basisghana)`
variables and `r nrow(basisghana)` observations. For an overview
of the variable names, see the following table.

```{r, eval=FALSE}
basisghana
```

```{r, echo=FALSE}
readr::read_csv("data-raw/dictionary.csv") |>
dplyr::filter(file_name == "basisghana.rda") |>
dplyr::select(variable_name:description) |>
knitr::kable()
```

The `ghanapop` data set has `r ncol(ghanapop)`
variables and `r nrow(ghanapop)` observations. For an overview
of the variable names, see the following table.

```{r, eval=FALSE}
ghanapop
```

```{r, echo=FALSE}
readr::read_csv("data-raw/dictionary.csv") |>
dplyr::filter(file_name == "ghanapop.rda") |>
dplyr::select(variable_name:description) |>
knitr::kable()
```

## Example

```{r, echo=FALSE}
library(basisghana)
library(dplyr)
library(tidyverse)

basisghana <- basisghana |>
rename(district_en = "district") |>
mutate(district_en = case_when(
district_en == "Abura Asebu Kwamankes" ~ "Abura-Asebu-Kwamankese",
district_en == "Ajumako Enyan Essiam" ~ "Ajumako-Enyan-Essiam",
district_en == "Asikuma Odoben Brakwa" ~ "Asikuma-Odoben-Brakwa",
district_en == "Bawku" ~ "Bawku Municipal",
district_en == "Bunkpurugu" ~ "Bunkpurugu Nakpanduri",
district_en == "Daffiama Bussie Iss" ~ "Daffiama Bussie Issa",
district_en == "East Gonja" ~ "East Gonja Municipal",
district_en == "Garu Tempane" ~ "Garu",
district_en == "Ho" ~ "Ho Municipal",
district_en == "Hohoe" ~ "Hohoe Municipal",
district_en == "Keta" ~ "Keta Municipal",
district_en == "Kpando Municipa" ~ "Kpando Municipal",
district_en == "Lambussie Karni" ~ "Lambussie-Karni",
district_en == "Nadowli Kaleo" ~ "Nadowli-Kaleo",
district_en == "Sagnarigu" ~ "Sagnerigu",
district_en == "Tatale" ~ "Tatale Sanguli",
district_en == "West Mamprusi" ~ "West Mamprusi Municipal",
district_en == "Yendi" ~ "Yendi Municipal",
district_en == "Damongo" ~ "West Gonja",
TRUE ~ district_en
))
```

### 1) Extracting the Top 10 Districts with the Highest Percentage of ODF Communities in Ghana

The following code demonstrates how to calculate the percentage of ODF communities per region in Ghana. This computation involves using ODF population data sourced from the basisghana dataset, in conjunction with total population statistics categorized by region, sourced from the ghanapop dataset.

```{r example}
library(tidyverse)
library(basisghana)
library(dplyr)

odf_by_district <- basisghana |>
group_by(district_en) |>
summarize(odf_population = sum(population, na.rm = TRUE))

odf_by_district <- merge(odf_by_district, ghanapop, by = 'district_en', all = TRUE) |>
mutate(percentage = round(odf_population / total_pop * 100, 2)) |>
arrange(desc(percentage))

top_10_odf <- odf_by_district |>
top_n(10, percentage) |>
select(district_en, region_en, percentage) |>
mutate(percentage = paste0(percentage, "%")) |>
rename(
district = "district_en",
region = "region_en",
`proportion ODF population in district` = "percentage"
)

top_10_odf
```

### 2) Mapping the Regions with highest percentage of ODF communities in Ghana

The code uses the dataset of ODF communities categorized by districts (see above), which are then aggregated based on regions in Ghana. It's important to note that the reference to Ghana's regions pertains to the former 10 regions preceding the 2018 referendum, which subsequently led to the establishment of new regions, resulting in a total of 16 regions from 2020 (Refer to [Regions of Ghana](https://en.wikipedia.org/wiki/Regions_of_Ghana)). From the collected data across 5 of these former regions, a color-coded map of Ghana depicts the varying proportions of Open Defecation Free (ODF) communities in each region.

```{r}
library(sf)
library(rnaturalearth)
library(ggplot2)

#group the regions according to how they were back in 2017 (10 regions instead of 16)
odf_by_region <- odf_by_district |>
mutate(region_en = case_when(
region_en %in% c("Bono", "Bono East", "Ahafo") ~ "Brong Ahafo",
region_en %in% c("Northern", "Savannah", "Northern East") ~ "Northern",
region_en %in% c("Volta", "Oti") ~ "Volta",
region_en %in% c("Western", "Western North") ~ "Western",
TRUE ~ as.character(region_en)
)) |>
group_by(region_en) |>
summarize(
odf_population = sum(odf_population, na.rm = TRUE),
female = sum(female_pop, na.rm = TRUE),
male = sum(male_pop, na.rm = TRUE),
total_pop = sum(total_pop, na.rm = TRUE)
) |>
mutate(percentage = round(odf_population / total_pop * 100, 2)) |>
arrange(desc(percentage)) |>
filter(!is.na(region_en)) |>
select(region_en, percentage)

ghana <- ne_states(country = "Ghana", returnclass = "sf") |>
rename(
region_en = "name"
)

ggplot() +
theme_void() +
geom_sf(data = full_join(ghana, odf_by_region, by = "region_en"), aes(fill = percentage), color = "white", lwd = 0) +
scale_fill_gradientn(name = paste("Percentage of ODF population", "\n by region (logarithmic scale)"),
trans = "log",
labels = scales::label_number(accuracy = 1),
colors = c("#2E8B57","#9DBF9E", "#FCB97D", "#A84268"),
na.value = "grey80") +
labs(title = paste("Regions with highest percentage of ODF communities", "\n in Ghana (2017)")) +
theme_minimal() +
theme(
plot.title = element_text(size = 14),
plot.margin = margin(1, 1, 1, 1, "cm")
)
```

*Note: A logarithmic scale has been employed to accentuate distinctions among lower percentage values.*

## License

Data are available as
[CC-BY](https://github.com/openwashdata/basisghana/LICENSE.md).

## Citation

To cite this package, please use:

```{r}
citation("basisghana")
```