Adding a package
Scaffold, house style, and shared assets for a new malariaverse package
This is a maintainer-facing page, and part of the packages pillar of maintenance. See also Versioning & releases and Governance.
A malariaverse package is just an ordinary R package that meets a small minimum bar and follows a few shared conventions so it looks and behaves like its siblings. This page is the checklist for creating one.
Minimum bar
A package is ready to join the malariaverse when it:
- passes
R CMD checkcleanly on GitHub Actions, - has a test suite (
testthat), - has a published
pkgdownsite, - has a hex logo and a
READMEcarrying a repostatus status badge, and - has a card added to the malariaverse home page.
Governance for who signs off on a new package is on the Governance page.
Scaffold with usethis
The existing packages were all scaffolded with usethis + the r-lib/actions workflows, so new packages should be too — it keeps the CI identical across the suite and avoids hand-rolled config drifting out of date.
# 1. Create the package
usethis::create_package("mypkg")
usethis::use_mit_license("Imperial College of Science, Technology and Medicine") # or as appropriate
usethis::use_git()
usethis::use_github(organisation = "mrc-ide")
# 2. Tests
usethis::use_testthat()
usethis::use_test("myfunction")
# 3. Continuous integration (matches the rest of the suite)
usethis::use_github_action("check-standard") # -> .github/workflows/check-standard.yaml
usethis::use_github_action("test-coverage") # -> .github/workflows/test-coverage.yaml
# 4. pkgdown site + GitHub Pages deploy
usethis::use_pkgdown_github_pages() # creates _pkgdown.yml + .github/workflows/pkgdown.yaml
# 5. README with badges
usethis::use_readme_rmd()This is the CI layout to aim for: check-standard.yaml, pkgdown.yaml and test-coverage.yaml, so that a maintainer moving between repos finds CI in the same place. site, postie and netz already follow it.
Note that the older packages do not, and are not worth churning just for consistency: cali uses R-CMD-check.yaml in place of check-standard.yaml, and malariasimulation has R-CMD-check.yaml, pkgdown.yml (note the extension) and touchstone.yaml for benchmarking, with no test-coverage workflow. If you are looking at an existing package and its CI does not match the scaffold above, that is why.
Depending on other mrc-ide packages
mrc-ide packages are installed from GitHub, not CRAN, so declare them in both Imports:/Suggests: and Remotes: in DESCRIPTION (the r-lib/actions check installs Remotes automatically via pak):
Imports:
malariasimulation
Remotes:
mrc-ide/malariasimulationBefore releasing a change that other packages depend on, follow the compatibility checks on the Versioning & releases page.
pkgdown conventions
template: bootstrap: 5(all suite sites use Bootstrap 5).For a package that will announce breaking changes, add a 📢 Latest changes navbar component pointing at a
Latest-changesarticle — this is the suite’s release-communication convention (see Versioning & releases). Example fromsite/_pkgdown.yml:navbar: structure: left: [intro, changes, articles, news] right: [search, github] components: changes: text: 📢 Latest changes href: articles/Latest-changes.html
Because pkgdown serves man/figures/ at reference/figures/ on the built site, the malariaverse home page can pull each hex logo live from https://mrc-ide.github.io/<pkg>/reference/figures/<Pkg>.png.
House visual style
The canonical plotting style lives in the site package (R/plot.R, exported), built around navy #1B2A6C. Reuse it — don’t reinvent it.
- If your package already depends on
site, callsite::theme_site()and thesitepalette helpers directly. - Otherwise, reproduce the same look. The pieces are:
# Navy used throughout
navy <- "#1B2A6C"
# theme_site(): theme_bw() with navy axis/title text, no minor gridlines,
# no major x gridline, rotated x labels, default 1/3 aspect ratio.
theme_site <- function(aspect.ratio = 1 / 3) {
ggplot2::theme_bw() +
ggplot2::theme(
legend.background = ggplot2::element_blank(),
panel.grid.minor = ggplot2::element_blank(),
panel.grid.major.x = ggplot2::element_blank(),
axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1, colour = navy),
axis.text.y = ggplot2::element_text(colour = navy),
axis.title = ggplot2::element_text(colour = navy),
plot.title = ggplot2::element_text(colour = navy, face = "bold", size = 12),
aspect.ratio = aspect.ratio
)
}The shared palettes (also in site::):
| Helper | Purpose | Colours |
|---|---|---|
site_age_palette(n) |
ordered/sequential (age groups) | ramp of #2A9D8F → #E9C46A → #E76F51 |
site_vector_palette(n) |
categorical (vector species) | #2A9D8F, #E76F51, #1B2A6C, #E9C46A, #D81B60, #6A4C93, #1982C4, #FF595E |
| prevalence colours | Pf / Pv | pfpr = #D81B60, pvpr = #1E88E5 |
This is the palette as it exists in code today — it is not the Okabe-Ito palette. If the group decides to move to a colourblind-safe standard in future, change it in site:: and have other packages inherit from there, so the suite stays consistent.