-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
134 lines (93 loc) · 4.81 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
message = FALSE,
collapse = TRUE,
comment = "#>"
)
```
# R workflow for Simple Spatial Surveys Method (S3M) survey in Mozambique
<!-- badges: start -->
[![test S3M workflow](https://github.com/katilingban/mozambique_s3m/actions/workflows/test-s3m-workflow.yaml/badge.svg)](https://github.com/katilingban/mozambique_s3m/actions/workflows/test-s3m-workflow.yaml)
[![check endline data](https://github.com/katilingban/mozambique-s3m/actions/workflows/check-s3m-data.yaml/badge.svg)](https://github.com/katilingban/mozambique-s3m/actions/workflows/check-s3m-data.yaml)
<!-- badges: end -->
This repository is a [`docker`](https://www.docker.com/get-started)-containerised, [`{targets}`](https://docs.ropensci.org/targets/)-based, [`{renv}`](https://rstudio.github.io/renv/articles/renv.html)-enabled [`R`](https://cran.r-project.org/) workflow developed for the design, data management, data analysis, and reporting of the implementation of Simple Spatial Surveys Method (S3M) survey in Mozambique.
## Repository Structure
* `data/` contains intermediate data outputs produced by the workflow including a survey codebook describing all variables;
* `R/` contains functions created for use in this workflow;
* `reports/` contains literate code for R Markdown reports generated in the workflow;
* `outputs/` contains compiled reports and figures;
* `auth/` contains credentials for Google service account (see below for more information);
* `docs/` contains archived high frequency data checks reports produced during the implementation of the survey;
* `_targets.R` file defines the steps in this workflow's data management and analysis pipeline.
## Reproducibility
### R package dependencies
This project requires `R 4.2.2 Patched (2022-11-10 r83330)`. This project uses the `{renv}` framework to record R package dependencies and versions. Packages and versions used are recorded in renv.lock and code used to manage dependencies is in renv/ and other files in the root project directory. On starting an R session in the working directory, `run renv::restore()` to install R package dependencies.
### Data management and analysis
This project uses the targets package to create its data management and analysis pipeline as defined in the `_targets.R` file.
* To execute the data management and processing workflow, run:
```
targets::tar_make(recoded_data)
```
The schematic figure below summarizes the steps in the data management and processing workflow:
```{r data_management_workflow, echo = FALSE, message = FALSE, results = 'asis'}
cat(
"```mermaid",
targets::tar_mermaid(
targets_only = TRUE,
names = c(
raw_data, raw_data_clean, raw_data_clean_translated,
sofala_district_population, sofala_ea_population, recoded_data
)
),
"```",
sep = "\n"
)
```
* To execute the data analysis workflow, run:
```
targets::tar_make(indicator_results_districts_xlsx)
targets::tar_make(indicator_results_overall_xlsx)
targets::tar_make(dplyr::contains("interpolation_maps"))
targets::tar_make(dplyr::contains("choropleth_maps"))
```
The schematic figure below summarizes the steps in the data management and processing workflow:
```{r data_analysis_workflow, echo = FALSE, message = FALSE, results = 'asis'}
cat(
"```mermaid",
targets::tar_mermaid(
targets_only = TRUE,
names = c(
indicator_results_districts_xlsx, indicator_results_overall_xlsx,
dplyr::contains("interpolation_maps"), dplyr::contains("choropleth_maps")
)
),
"```",
sep = "\n"
)
```
## Encryption
This repository uses `git-crypt` to enable transparent encryption and decryption of the `.env` file.
The `.env` file contains:
* variables for accessing the survey data direct from ONA;
* variables for authenticating with Google services account setup for this project;
* variables for `SMTP_PASSWORD` and `EMAIL_RECIPIENTS` which are used for sending the email updates for the high frequency data checks.
Those who would like to reproduce the results of this project will require ability to decrypt the `.env` file
To be able to work on this repository, a potential user/collaborator on this project will need to:
* Create their own PGP (Pretty Good Privacy) public and private keys; and,
* Share their public key to the authors and request for it to be added to the repository.
Once added, a collaborator can now decrypt the .env file after pulling/cloning the repository by running:
```
git-crypt unlock
```
on the terminal.
## Authors
* Mark Myatt
* Ernest Guevarra
## License
This work is licensed under a GNU General Public License 3 (GPL-3).
## Feedback
Feedback, bug reports and feature requests are welcome; file issues or seek support [here](https://github.com/katilingban/mozambique-s3m/issues).