-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial fully functioning package (#11)
* initial commit for CFR calculation * removing duplicate/redudant functions for new approach * editing README to include new use case for Ebola * adding initial plot * adding ggplot2 dependency and sourcing plotting functions * changing README to reflect changes to script * adding plot to README * fixing plot in README * fixing plot * removing plot from README * removing data.table dependency and adding package structure for existing functions * Add unit tests and related snapshots * Remove scripts and plots dirs * Add R CMD check, test-coverage, linter workflows * Add Ebola 1976 outbreak data to package * Add Ebola 1976 data file to extdata * Add package infrastructure files * Clean static_cfr + exs, output is named vector * Clean rolling_cfr + exs, use data.table * Simplify ccfr_uncertainty, output is named vec * Input checks format_cfr, add full example * Clean known_outcomes + example * Update plot fun with input checking and namespacing * Remove old snapshot * Add datadelay package file * Add revised documentation * Update DESCR, epiparam to sgsts, rm lubridate/reshap2, add data.table * Rm ggplot funs, add data.table funs to NAMESPACE * Use README.Rmd, add example from scripts * Add render-readme workflow * Install epiparameter from Github * Fix linter errors * Ebola data uses Date class * Allow deaths equal to cases * Check delay_pmf only if passed * Add Covid-19 USA example * Add to gitignore * Add {covidregionaldata} to suggests * Use GH version of {covidregionaldata} * Update snapshot for dataframe not datatable * Correct rolling_cfr TESTS * Add author, add rlang dep * Rename ccfr_estimation to estimate_ccfr * Input checking and full matching for known_outcomes * Initialise output objs, reorder correction workflow * Use .data pronoun from rlang * Update documentation * Correct README to use delay_pmf * Update plot snapshot and package namespace script * Update check workflows * Style and add dependency R > 3.5.0 * Automatic readme update * Vectorise likelihood calculation * Add figures, fix style, fix examples * Automatic readme update * Correct convolution, fixes #17 * Correct likelihood calculation, fixes #18 * Rewrite `rolling_cfr` to avoid repeated `static_cfr` calls * Minor corrections; update documentation * Correct snapshots * Update data documentation * Update README figures * Update static CFR print format Co-authored-by: Adam Kucharski <adam.kucharski@lshtm.ac.uk> * Update print CFR snapshots * Clarify rolling CFR as real-time CFR Co-authored-by: Adam Kucharski <adam.kucharski@lshtm.ac.uk> * Automatic readme update * Add usethis to suggests Co-authored-by: thimotei <timothywilliamrussell@gmail.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Adam Kucharski <adam.kucharski@lshtm.ac.uk>
- Loading branch information
1 parent
53ba149
commit a37b6c3
Showing
53 changed files
with
2,019 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
^datadelay\.Rproj$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^\.github$ | ||
^codecov\.yml$ | ||
^README\.Rmd$ | ||
^\.lintr$ | ||
^data-raw$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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 | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
name: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ${{ matrix.config.os }} | ||
|
||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: macos-latest, r: 'release'} | ||
- {os: windows-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} | ||
- {os: ubuntu-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'oldrel-1'} | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: ${{ matrix.config.r }} | ||
http-user-agent: ${{ matrix.config.http-user-agent }} | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 | ||
with: | ||
upload-snapshots: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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 | ||
on: | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: lint-changed-files | ||
|
||
jobs: | ||
lint-changed-files: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
any::gh | ||
any::lintr | ||
any::purrr | ||
epiverse-trace/etdev | ||
needs: check | ||
|
||
- name: Add lintr options | ||
run: | | ||
cat('\noptions(lintr.linter_file = ".lintr")\n', file = "~/.Rprofile", append = TRUE) | ||
shell: Rscript {0} | ||
|
||
- name: Install package | ||
run: R CMD INSTALL . | ||
|
||
- name: Extract and lint files changed by this PR | ||
run: | | ||
files <- gh::gh("GET https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files") | ||
changed_files <- purrr::map_chr(files, "filename") | ||
all_files <- list.files(recursive = TRUE) | ||
exclusions_list <- as.list(setdiff(all_files, changed_files)) | ||
lintr::lint_package(exclusions = exclusions_list) | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Name of the workflow | ||
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: | ||
paths: | ||
- 'README.Rmd' | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
render-readme: | ||
runs-on: macos-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout repos | ||
uses: actions/checkout@v2 | ||
|
||
- 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: | | ||
tf <- tempfile(fileext = ".Rmd") | ||
writeLines( | ||
knitr::knit_expand( | ||
"README.Rmd", | ||
packagename = read.dcf("DESCRIPTION", "Package"), | ||
gh_repo = Sys.getenv("GITHUB_REPOSITORY") | ||
), | ||
tf | ||
) | ||
rmarkdown::render(tf, 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 push origin || echo "No changes to push" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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 | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
name: test-coverage | ||
|
||
jobs: | ||
test-coverage: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::covr | ||
needs: coverage | ||
|
||
- name: Test coverage | ||
run: | | ||
covr::codecov( | ||
quiet = FALSE, | ||
clean = FALSE, | ||
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") | ||
) | ||
shell: Rscript {0} | ||
|
||
- name: Show testthat output | ||
if: always() | ||
run: | | ||
## -------------------------------------------------------------------- | ||
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true | ||
shell: bash | ||
|
||
- name: Upload test results | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-test-failures | ||
path: ${{ runner.temp }}/package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
.DS_Store | ||
docs | ||
inst/doc | ||
/doc/ | ||
/Meta/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
linters: linters_with_tags( | ||
tags = NULL, # include all linters | ||
object_name_linter = NULL, | ||
undesirable_function_linter = NULL, | ||
implicit_integer_linter = NULL, | ||
extraction_operator_linter = NULL, | ||
todo_comment_linter = NULL, | ||
function_argument_linter = NULL, | ||
# Use minimum R declared in DESCRIPTION or fall back to current R version | ||
backport_linter(if (length(x <- etdev::extract_min_r_version())) x else getRversion()) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,50 @@ | ||
Package: datadelay | ||
Title: Delay Functions for Epidemic Data | ||
Version: 0.1 | ||
Authors@R: | ||
person("Adam", "Kucharski", , "adam.kucharski@lshtm.ac.uk", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-8814-9421")) | ||
Authors@R: c( | ||
person( | ||
given = "Adam", | ||
family = "Kucharski", | ||
email = "adam.kucharski@lshtm.ac.uk", | ||
role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-8814-9421") | ||
), | ||
person( | ||
given = "Tim", | ||
family = "Russell", | ||
email = "timothy.russell@lshtm.ac.uk", | ||
role = c("aut"), | ||
comment = c(ORCID = "0000-0001-5610-6080") | ||
), | ||
person( | ||
given = "Pratik", | ||
family = "Gupte", | ||
role = c("aut"), | ||
email = "pratik.gupte@lshtm.ac.uk", | ||
comment = c(ORCID = "0000-0001-5294-7819") | ||
) | ||
) | ||
Description: Delay functions for routine surveillance data. | ||
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a | ||
license | ||
License: MIT + file LICENSE | ||
URL: https://github.com/epiverse-trace/datadelay | ||
BugReports: https://github.com/epiverse-trace/datadelay/issues | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.1.2 | ||
RoxygenNote: 7.2.2 | ||
Imports: | ||
data.table, | ||
ggplot2, | ||
patchwork, | ||
rlang | ||
Suggests: | ||
testthat (>= 3.0.0), | ||
epiparameter, | ||
covidregionaldata, | ||
usethis | ||
Remotes: | ||
epiverse-trace/epiparameter, | ||
epiforecasts/covidregionaldata | ||
Config/testthat/edition: 3 | ||
Depends: | ||
R (>= 3.5.0) | ||
LazyData: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(cases_to_infections) | ||
export(cfr_calculation) | ||
export(estimate_ccfr) | ||
export(format_cfr_neatly) | ||
export(known_outcomes) | ||
export(plot_data_and_cfr) | ||
export(rolling_cfr) | ||
export(static_cfr) | ||
importFrom(data.table,":=") | ||
importFrom(data.table,.BY) | ||
importFrom(data.table,.EACHI) | ||
importFrom(data.table,.GRP) | ||
importFrom(data.table,.I) | ||
importFrom(data.table,.N) | ||
importFrom(data.table,.NGRP) | ||
importFrom(data.table,.SD) | ||
importFrom(data.table,data.table) | ||
importFrom(rlang,.data) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.