Skip to content

The-Strategy-Unit/723_mh_covid_surge_modelling

Repository files navigation

Mental Health Surge Modelling The Strategy Unit Logo

Lifecycle: stable R build status Codecov test coverage License: MIT

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. Documentation for the code is available at the-strategy-unit.github.io/723_mh_covid_surge_modelling.

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 and IAPT datasets within NCDR.

Usage

devtools::install_github("The-Strategy-Unit/723_mh_covid_surge_modelling")
mhSurgeModelling::run_app()

Project Structure

This package uses the {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} 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} 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. You can then 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:

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.

source("dev/run_dev.R", echo = TRUE)

As this is a package you need to follow package development practices; reading the 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.

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 to quickly identify issues.

The package documentation is built using pkgdown. This is done automatically on 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 to discuss any bugs or changes before filing a pull request.

Deployment

This package has been configured to use CI/CD with GitHub Actions. There are currently 5 actions:

  • lintr runs static code analysis to check for syntactical errors and code styling issues. This runs on all commits.
  • r-cmd-check runs R CMD CHECK. This runs on all commits.
  • covr uploads test coverage to codecov.io
  • shiny deploy runs only on successful PR’s to master and deploys the application.
  • pkgdown runs only on successful PR’s to master and deploys the documentation.