-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
138 lines (102 loc) · 4 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(tidyverse)
library(epoxy)
library(leaflet)
library(chckapmalawi)
```
# chckapmalawi
<!-- badges: start -->
[![DOI](https://zenodo.org/badge/709679915.svg)](https://zenodo.org/doi/10.5281/zenodo.10459432)
[![R-CMD-check](https://github.com/openwashdata/chckapmalawi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/openwashdata/chckapmalawi/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
This packages compiles insights from a Knowledge, Attitudes, and Practices (KAP) Survey conducted by [BASEflow](https://baseflowmw.org/) for Waste Advisers in Malawi, focusing on Community Health Centers (CHCs).
## Installation
You can install the development version of chckapmalawi from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("openwashdata/chckapmalawi")
```
Alternatively, you can download the individual dataset as a CSV or XLSX
file from the table below.
```{r, echo=FALSE}
library(dplyr)
library(stringr)
library(readr)
extdata_path <- "https://github.com/openwashdata/chckapmalawi/raw/main/inst/extdata/"
read_csv("data-raw/dictionary.csv", col_types = cols(.default = "c")) |>
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(show_col_types = FALSE)
```
## Project goal
## Data
The data set covers diverse aspects including household demographics, CHC membership, water sources, sanitation, nutrition knowledge, hygiene practices, and environmental conditions. It was collected in 20XX.
The package provides access to a single data sets.
```{r, echo = TRUE}
library(chckapmalawi)
```
The `chckapmalawi` data set has `r ncol(chckapmalawi)`
variables and `r nrow(chckapmalawi)` observations. For an overview
of the variable names, see the following table.
```{r, eval=FALSE}
chckapmalawi
```
```{r, echo=FALSE}
readr::read_csv("data-raw/dictionary.csv", col_types = cols(.default = "c")) |>
dplyr::filter(file_name == "chckapmalawi.rda") |>
dplyr::select(variable_name:description) |>
knitr::kable()
```
## Example
### Visualizing Vegetable Distribution in Malawi Gardens
This code snippet utilizes rAmCharts4 in R to visualize vegetable diversity in Malawian gardens. By displaying the distribution of crops grown, it highlights how Malawians can self-provide a diverse range of vegetables, crucial for a balanced diet.
```{r}
library(dplyr)
library(tidyr)
library(rAmCharts4)
chckapmalawi$vegetables_grown_in_garden <- gsub("Other \\(please specify\\)", "Other", chckapmalawi$vegetables_grown_in_garden)
split_data <- chckapmalawi |>
separate_rows(vegetables_grown_in_garden, sep = ",\\s*") |>
mutate(vegetables_grown_in_garden = trimws(vegetables_grown_in_garden)) |>
filter(vegetables_grown_in_garden != "")
vegetable_freq <- table(split_data$vegetables_grown_in_garden)
vegetable_freq_df <- as.data.frame(vegetable_freq)
names(vegetable_freq_df) <- c("Vegetable", "Frequency")
vegetable_freq_df$Percentage <- vegetable_freq_df$Frequency / sum(vegetable_freq_df$Frequency) * 100
chart <- amPieChart(
data = vegetable_freq_df,
category = "Vegetable",
value = "Frequency",
depth = 30,
legend = FALSE,
chartTitle = "Vegetables Grown in Garden (Malawi)",
animated = 1,
theme = "spiritedaway"
)
```
```{r, echo=FALSE, fig.cap="Screenshot of an interactive pie chart with rAmCharts4", out.width='75%'}
knitr::include_graphics("man/figures/vegetables_plot.png")
```
## License
Data are available as
[CC-BY](https://github.com/openwashdata/basisghana/LICENSE.md).
## Citation
To cite this package, please use:
```{r}
citation("chckapmalawi")
```