Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/dependency-change.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
# Adapted from Epiverse packages: https://github.com/epiverse-trace
on:
pull_request:
paths:
- 'DESCRIPTION'

name: Analyze dependency changes

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
pull-requests: write

jobs:
dependency-changes:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: any::pak, glue, gh

- name: Analyze dependency changes
shell: Rscript {0}
run: |
deps_base <- pak::pkg_deps("${{ github.repository }}@${{ github.base_ref }}", dependencies = TRUE) |>
subset(!directpkg) |>
subset(is.na(priority))
# We install from PR number rather than branch to deal with the case
# of PR coming from forks
deps_head <- pak::pkg_deps("${{ github.repository }}#${{ github.event.number }}", dependencies = TRUE) |>
subset(!directpkg) |>
subset(is.na(priority))

deps_added <- deps_head |>
subset(!ref %in% deps_base$ref)

deps_removed <- deps_base |>
subset(!ref %in% deps_head$ref)

if (nrow(deps_added) + nrow(deps_removed) > 0) {

message("Dependencies have changed! Analyzing...")

if (nrow(deps_added) > 0) {
nudge <- "Reach out on slack (`#code-review` or `#help` channels) to double check if there are base R alternatives to the new dependencies.\n"
} else {
nudge <- ""
}

msg <- glue::glue(
.sep = "\n",
"This pull request:",
"- Adds {nrow(deps_added)} new dependencies (direct and indirect)",
"- Adds {length(unique(deps_added$sysreqs))} new system dependencies",
"- Removes {nrow(deps_removed)} existing dependencies (direct and indirect)",
"- Removes {length(unique(deps_removed$sysreqs))} existing system dependencies",
"",
nudge,
"(Note that results may be inaccurate if you branched from an outdated version of the target branch.)"
)

message("Posting results as a pull request comment.")

gh::gh(
"POST /repos/{repo}/issues/{issue_number}/comments",
repo = "${{ github.repository }}",
issue_number = "${{ github.event.number }}",
body = msg
)

}
97 changes: 97 additions & 0 deletions .github/workflows/render-readme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Adapted from Epiverse packages: https://github.com/epiverse-trace
# Reproduce locally by running:
# ```r
# pak::pak(c("any::rmarkdown", "any::usethis", "."))
# writeLines(
# knitr::knit_expand(
# "README.Rmd",
# packagename = read.dcf("DESCRIPTION", "Package"),
# gh_repo = usethis:::github_remote_list()$repo_spec
# ),
# "README_expanded.Rmd"
# )
# rmarkdown::render(
# "README_expanded.Rmd",
# output_file = "README.md",
# output_dir = "."
# )
# unlink("README_expanded.Rmd")
# ```
name: render-readme

# Controls when the action will run. Triggers include:
#
# - button trigger from github action page
# - on changes to readme.Rmd

on:
workflow_dispatch:
push:
branches:
# This may seem like a no-op but it prevents triggering on tags
# We use '**' rather '*' to accomodate names like 'dev/branch-1'
- '**'
paths:
- 'README.Rmd'
- '.github/workflows/render_readme.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
render-readme:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repos
uses: actions/checkout@v4

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Setup pandoc
uses: r-lib/actions/setup-pandoc@v2

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rmarkdown, local::.

- name: Compile the readme
run: |
writeLines(
knitr::knit_expand(
"README.Rmd",
packagename = read.dcf("DESCRIPTION", "Package"),
gh_repo = Sys.getenv("GITHUB_REPOSITORY")
),
"README_expanded.Rmd"
)
rmarkdown::render(
"README_expanded.Rmd",
output_file = "README.md",
output_dir = "."
)
shell: Rscript {0}

- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
# Also add README figures if they exist
if [ -d man/figures ]
then
git add man/figures/
fi
git diff-index --quiet HEAD || git commit -m "Automatic readme update"
git pull --rebase origin ${{ github.ref.name }}
git push origin || echo "No changes to push"
38 changes: 38 additions & 0 deletions .github/workflows/update-copyright-year.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Adapted from Epiverse packages: https://github.com/epiverse-trace
name: Update copyright year(s) in license file

on:
workflow_dispatch:
schedule:
- cron: '0 3 1 1 *'

permissions:
contents: write
pull-requests: write

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: FantasticFiasco/action-update-license-year@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: |
LICENSE.md
prBody: >
This PR updates the copyright license for this new year! If you're reading this while you're celebrating, enjoy! Don't worry about this one :blush:

![Happy new year!](https://media.giphy.com/media/HyDfNCZlTn5iU/giphy.gif?cid=ecf05e4777yl7dbo1xfha6bx1z5lrl13uq7biv6rs9dqsyoh&ep=v1_gifs_search&rid=giphy.gif&ct=g)
- uses: FantasticFiasco/action-update-license-year@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: |
LICENSE
prBody: >
This PR updates the copyright license for this new year! If you're reading this while you're celebrating, enjoy! Don't worry about this one :blush:

![Happy new year!](https://media.giphy.com/media/HyDfNCZlTn5iU/giphy.gif?cid=ecf05e4777yl7dbo1xfha6bx1z5lrl13uq7biv6rs9dqsyoh&ep=v1_gifs_search&rid=giphy.gif&ct=g)
transform: (?<=YEAR:\s)(?<from>\d{4})?-?(\d{4})?
6 changes: 1 addition & 5 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
linters: all_linters(
indentation_linter = NULL, # unstable as of lintr 3.1.0
extraction_operator_linter = NULL, # lints auto-generated vignette setup chunks
implicit_integer_linter = NULL, # turn off due to multiple integerish values used
duplicate_argument_linter = NULL, # due to cli_bullets
object_name_linter = NULL, # due to S3 methods
Expand All @@ -20,8 +19,5 @@ exclusions: list(
),
"vignettes" = list(
undesirable_function_linter = Inf
),
# do no attempt to lint auto-generated files
"R/RcppExports.R",
"R/cpp11.R"
)
)
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Description: Your package description. It must end with a period (".") and
include relevant bibliographical references if applicable, using the
following format: Author et al. (2023) <doi:10.5281/zenodo.6619350>.
License: MIT + file LICENSE
URL: https://github.com/vimc/vimc.rpkg.template,
https://vimc.github.io/vimc.rpkg.template/
BugReports: https://github.com/vimc/vimc.rpkg.template/issues
Suggests:
knitr,
rmarkdown,
Expand Down
12 changes: 7 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
output: github_document
# add bibliography here
# NOTE: place references if any as a JSON in `vignettes/resources`
# NOTE: references file can have any name, and there can be separate references per vignette
bibliography: vignettes/resources/references.json
link-citations: true
---

Expand Down Expand Up @@ -33,9 +35,7 @@ Replace all instances of `"vimc.rpkg.template"` with your package name. Make sur

2. Edit the files in `R/`, `tests/`, and `vignettes/` to suit your package;

3. Add spell check by running `usethis::use_spell_check(lang = "en-GB")`;

4. Remove these instructions from `README.Rmd`, and re-render the `.md` file using `devtools::render_readme()`.
3. Remove these instructions from `README.Rmd`. Then, either let the automated GitHub Actions workflow update `README.md` once the change is pushed to GitHub, or disable the workflow by removing the file `.github/workflows/render-readme.yaml`, and manually re-render the `.md` file using `devtools::render_readme()`.

## Installation

Expand Down Expand Up @@ -71,6 +71,8 @@ If preparatory or plotting steps are needed, prefer to hide them to keep focus o

Add information and links to related projects, such as research papers or packages, here.

An example citation would be @echeverria-londono2021.

## References

Space for references: REMOVE this text.
**Space for references: REMOVE this sub-section if there are no references. References, if any, should appear below this text. Remove this text in packages.**
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ VIMC GitHub organisation. Replace all instances of
2. Edit the files in `R/`, `tests/`, and `vignettes/` to suit your
package;

3. Add spell check by running
`usethis::use_spell_check(lang = "en-GB")`;

4. Remove these instructions from `README.Rmd`, and re-render the `.md`
file using `devtools::render_readme()`.
3. Remove these instructions from `README.Rmd`. Then, either let the
automated GitHub Actions workflow update `README.md` once the change
is pushed to GitHub, or disable the workflow by removing the file
`.github/workflows/render-readme.yaml`, and manually re-render the
`.md` file using `devtools::render_readme()`.

## Installation

Expand Down Expand Up @@ -75,6 +75,26 @@ prefer to hide them to keep focus on the package functionality.
Add information and links to related projects, such as research papers
or packages, here.

An example citation would be Echeverria-Londono et al.
([2021](#ref-echeverria-londono2021)).

## References

Space for references: REMOVE this text.
**Space for references: REMOVE this sub-section if there are no
references. References, if any, should appear below this text. Remove
this text in packages.**

<div id="refs" class="references csl-bib-body hanging-indent"
entry-spacing="0">

<div id="ref-echeverria-londono2021" class="csl-entry">

Echeverria-Londono, Susy, Xiang Li, Jaspreet Toor, Margaret J. De
Villiers, Shevanthi Nayagam, Timothy B. Hallett, Kaja Abbas, et al.
2021. “How Can the Public Health Impact of Vaccination Be Estimated?”
*BMC Public Health* 21 (1): 2049.
<https://doi.org/10.1186/s12889-021-12040-9>.

</div>

</div>
11 changes: 11 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
BMC
Codecov
Echeverria
Hallett
Jaspreet
Kaja
Londono
Nayagam
ORCID
Shevanthi
Susy
TAGLINE
Toor
VIMC
Xiang
doi
pkgdown
rpkg
Expand Down
9 changes: 9 additions & 0 deletions man/vimc.rpkg.template-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/spelling.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
if (requireNamespace("spelling", quietly = TRUE)) {
if (requireNamespace('spelling', quietly = TRUE))
spelling::spell_check_test(
vignettes = TRUE,
error = FALSE,
skip_on_cran = TRUE
)
}
9 changes: 0 additions & 9 deletions tests/testthat/helper-state.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
# function, or more conveniently with the `withr` package.
# We add a test on R >= 4.0.0 because some functions such as
# `globalCallingHandlers()` did not exist before.
get_pars_toreset <- function() {
pars <- par(no.readonly = TRUE)
# The following params are set and modified automatically by plot(), as
# documented in ?plot.window() and we:
# 1. have no control over them
# 2. do not care about resetting them
pars <- pars[!names(pars) %in% c("usr", "xaxp", "yaxp")]
}

if (getRversion() >= "4.0.0") {
testthat::set_state_inspector(function() {
list(
Expand Down
3 changes: 3 additions & 0 deletions vignettes/resources/references.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"id":"echeverria-londono2021","abstract":"Abstract\n \n Background\n Deaths due to vaccine preventable diseases cause a notable proportion of mortality worldwide. To quantify the importance of vaccination, it is necessary to estimate the burden averted through vaccination. The Vaccine Impact Modelling Consortium (VIMC) was established to estimate the health impact of vaccination.\n \n \n Methods\n We describe the methods implemented by the VIMC to estimate impact by calendar year, birth year and year of vaccination (YoV). The calendar and birth year methods estimate impact in a particular year and over the lifetime of a particular birth cohort, respectively. The YoV method estimates the impact of a particular year’s vaccination activities through the use of impact ratios which have no stratification and stratification by activity type and/or birth cohort. Furthermore, we detail an impact extrapolation (IE) method for use between coverage scenarios. We compare the methods, focusing on YoV for hepatitis B, measles and yellow fever.\n \n \n Results\n We find that the YoV methods estimate similar impact with routine vaccinations but have greater yearly variation when campaigns occur with the birth cohort stratification. The IE performs well for the YoV methods, providing a time-efficient mechanism for updates to impact estimates.\n \n \n Conclusions\n These methods provide a robust set of approaches to quantify vaccination impact; however it is vital that the area of impact estimation continues to develop in order to capture the full effect of immunisation.","accessed":{"date-parts":[["2025",12,9]]},"author":[{"family":"Echeverria-Londono","given":"Susy"},{"family":"Li","given":"Xiang"},{"family":"Toor","given":"Jaspreet"},{"family":"De Villiers","given":"Margaret J."},{"family":"Nayagam","given":"Shevanthi"},{"family":"Hallett","given":"Timothy B."},{"family":"Abbas","given":"Kaja"},{"family":"Jit","given":"Mark"},{"family":"Klepac","given":"Petra"},{"family":"Jean","given":"Kévin"},{"family":"Garske","given":"Tini"},{"family":"Ferguson","given":"Neil M."},{"family":"Gaythorpe","given":"Katy A. M."}],"citation-key":"echeverria-londono2021","container-title":"BMC Public Health","container-title-short":"BMC Public Health","DOI":"10.1186/s12889-021-12040-9","ISSN":"1471-2458","issue":"1","issued":{"date-parts":[["2021",12]]},"language":"en","page":"2049","source":"DOI.org (Crossref)","title":"How can the public health impact of vaccination be estimated?","type":"article-journal","URL":"https://bmcpublichealth.biomedcentral.com/articles/10.1186/s12889-021-12040-9","volume":"21"}
]
3 changes: 3 additions & 0 deletions vignettes/vimc-rpkg-template.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
title: "vimc-rpkg-template"
output: rmarkdown::html_vignette
# NOTE: make references if any available as a JSON at a location, see e.g. below
# NOTE: uncomment the line below, and update the references path as needed
# bibliography: resources/references.json
vignette: >
%\VignetteIndexEntry{vimc-rpkg-template}
%\VignetteEngine{knitr::rmarkdown}
Expand Down