-
Notifications
You must be signed in to change notification settings - Fork 8
/
Readme.Rmd
132 lines (95 loc) · 6.54 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
---
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%"
)
```
# Mental Health Surge Modelling [<img src="https://www.strategyunitwm.nhs.uk/themes/custom/ie_bootstrap/logo.svg" title="The Strategy Unit" alt="The Strategy Unit Logo" align="right" height="80"/>][su]
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![R build status](https://github.com/The-Strategy-Unit/723_mh_covid_surge_modelling/workflows/R-CMD-check/badge.svg)](https://github.com/The-Strategy-Unit/723_mh_covid_surge_modelling/actions)
[![Codecov test coverage](https://codecov.io/gh/The-Strategy-Unit/723_mh_covid_surge_modelling/branch/master/graph/badge.svg)](https://codecov.io/gh/The-Strategy-Unit/723_mh_covid_surge_modelling?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
<!-- badges: end -->
This package is a Shiny application to model the surge in mental health needs caused by the COVID-19 pandemic. It is
hosted at [strategyunit.shinyapps.io/MH\_Surge\_Modelling][app]. Documentation for the code is available at
[the-strategy-unit.github.io/723\_mh\_covid\_surge\_modelling][documentation].
The model framework has been guided by literature reviews and expert opinions. Data on population groups is sourced from
both routine and local data and variables for the model are based on a mixture of Trust returns and extracts from
[MHSDS][MHSDS] and [IAPT][IAPT] datasets within [NCDR][ncdr].
## Usage
```{r eval=FALSE}
devtools::install_github("The-Strategy-Unit/723_mh_covid_surge_modelling")
mhSurgeModelling::run_app()
```
## Project Structure
This package uses the [`{golem}`][golem] framework. All of the code is organised in the `R/` folder. The files are structured in the following way:
- `app_*.R` files are the main application files
- `run_app.R` is generated by the [`{golem}`][golem] framework and run's the entire application
- `module_*.R` files are the shiny modules for the application: each "page" has it's own module. These files contain
both the `ui` and `server` functions for that module
- `plot_*.R` files contain the code to produce the data for plots and the corresponding plot function. All plots for
the application are generated using the [`{plotly}`][plotly] package
- `utils_*.R` files contain the functions and utilities that are required by the application
- `ZZZ.R` contains extra code, such as what variables to load into the global environment at start up
Data files required at runtime by the application are stored in the `inst/app/data` folder:
- `params_help.json` contains the help text used on the `params` page
- `params_*.xlsx` files are the default parameters files included with the application
- `report.Rmd` is a RMarkdown report used to generate a `.pdf` download from the application
## Developing
If you wish to run this locally, first make a [fork in GitHub][fork]. You can then [clone][clone] the repository
directly in RStudio.
Once you have the repository cloned, you need to make sure that you have all of the package's dependencies installed:
```{r eval = FALSE}
remotes::install_deps(dependencies = TRUE)
```
Once the dependencies are installed the quickest way to run the application is to run the script `dev/run_dev.R`.
```{r eval = FALSE}
source("dev/run_dev.R", echo = TRUE)
```
As this is a package you need to follow package development practices; reading the [r-pkgs][r-pkgs] book is a great
start. In particular, make sure any dependecies on other packages are stated in the `DESCRIPTION` file and any functions
that you are importing are described using [roxygen2][roxygen2].
The `devtools` package is very useful to use during development. You can load the package to test code quickly using
`devtools::load_all()`, and documentation can be re-created using `devtools::document()`. It is worth running the latter
anytime you change code, especially when adding new functions or imports.
It is also worth regularly running [r-cmd-check][r-cmd-check] to quickly identify issues.
The package documentation is built using [pkgdown][pkgdown]. This is done automatically on [deployment](#deployment),
but you can view locally by running `pkgdown::build_site()`.
## Contributing
Contributions are welcome, but please note that this tool was developed for a specific project, so we may not be able to accept all changes. Please file an [issue][issue] to discuss any bugs or changes before filing a pull request.
## Deployment
This package has been configured to use [CI/CD][cicd] with [GitHub Actions][github-actions]. There are currently 5
actions:
- [lintr][lintr] runs static code analysis to check for syntactical errors and code styling issues. This runs on all
commits.
- [r-cmd-check][r-cmd-check] runs R CMD CHECK. This runs on all commits.
- [covr][covr] uploads test coverage to [codecov.io][codecov.io]
- shiny deploy runs only on successful PR's to master and deploys the [application][app].
- [pkgdown][pkgdown] runs only on successful PR's to master and deploys the [documentation][documentation].
[su]: https://www.strategyunitwm.nhs.uk/
[app]: https://strategyunit.shinyapps.io/MH_Surge_Modelling/
[documentation]: https://the-strategy-unit.github.io/723_mh_covid_surge_modelling/index.html
[issue]: https://github.com/The-Strategy-Unit/723_mh_covid_surge_modelling/issues/new
[mhsds]: https://data.england.nhs.uk/ncdr/database/NHSE_MH_V3_YTD/ "Mental health data (MHSDS v3)"
[iapt]: https://data.england.nhs.uk/ncdr/database/NHSE_IAPT/ "Improving access to psychological therapies (IAPT)"
[ncdr]: https://data.england.nhs.uk/ncdr/about/ "National Commissioning Data Repository (NCDR)"
[golem]: https://github.com/ThinkR-open/golem
[plotly]: https://plotly.com/r/
[fork]: https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo
[clone]: https://happygitwithr.com/rstudio-git-github.html#clone-the-new-github-repository-to-your-computer-via-rstudio
[r-pkgs]: https://r-pkgs.org/index.html
[roxygen2]: https://roxygen2.r-lib.org/
[r-cmd-check]: https://r-pkgs.org/r-cmd-check.html
[cicd]: https://en.wikipedia.org/wiki/CI/CD
[github-actions]: https://github.com/features/actions
[lintr]: https://github.com/jimhester/lintr
[pkgdown]: https://pkgdown.r-lib.org/
[covr]: https://covr.r-lib.org/
[codecov.io]: https://app.codecov.io/gh/The-Strategy-Unit/723_mh_covid_surge_modelling/