Skip to content

Commit

Permalink
Issue 40: Add example test data (#41)
Browse files Browse the repository at this point in the history
* Add example test data generation in data-raw and as .rda

* Make the test data internal

* Delete PNAS data (assume copied here from another package)

* Revert back to non-internal data

* Add data documentation

* Move simulated data generation from data-raw to tests/testthat

* Add PNAS ebola data in raw xlsx format with script for saving it to rda in data

* Remove simulated data from data/

* Clean the ebola column names

* Document ebola data

* Add readxl and janitor to Suggests

* Add newline to end of file

* Add ask to cite and spacing change

* Change name to "ebola_outbreak_sierra_leone" and document roxygen2

* Fix linter issues

* Rename to sierra_leone_ebola_outbreak_data

* Use shorter ebola data name, and change code style

Former-commit-id: d140527
Former-commit-id: 4ec821ababa950c635bdc96ad43a3dc1def7f70a
  • Loading branch information
athowes authored May 16, 2024
1 parent 920a1f2 commit 1cbaf82
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 8,360 deletions.
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Imports:
Suggests:
bookdown,
epinowcast,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
readxl,
janitor
Remotes:
stan-dev/cmdstanr,
Rdatatable/data.table,
Expand All @@ -42,3 +44,6 @@ Config/Needs/website:
epinowcast/enwtheme
Config/testthat/edition: 3
URL: https://epidist.epinowcast.org/
Depends:
R (>= 2.10)
LazyData: true
19 changes: 19 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#' Ebola linelist data from Fang et al. (2016)
#'
#' Linelist data for the Ebola virus collected in Sierra Leone. If you use this
#' data in your work, please cite the corresponding paper.
#'
#' @format A `tibble` with 8,358 rows and 8 columns:
#' \describe{
#' \item{id}{Unique identification number for the case}
#' \item{name}{Name as character, omitted}
#' \item{age}{Age as numeric}
#' \item{sex}{Sex as character, either "F", "M" or NA}
#' \item{date_of_symptom_onset}{The date symptoms began}
#' \item{date_of_sample_tested}{The date the sample was tested}
#' \item{district}{The district (ADM2)}
#' \item{chiefdom}{The chiefdom (ADM3)}
#' }
#' @family data
#' @source <https://www.pnas.org/doi/full/10.1073/pnas.1518587113>
"sierra_leone_ebola_data"
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ reference:
desc: Functions and helper functions for plotting
contents:
- has_concept("plot")
- title: Data
desc: Data included with the package
contents:
- has_concept("data")
8,359 changes: 0 additions & 8,359 deletions data-raw/pnas.1518587113.sd02.csv

This file was deleted.

Binary file added data-raw/pnas.1518587113.sd02.xlsx
Binary file not shown.
5 changes: 5 additions & 0 deletions data-raw/process_raw_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sierra_leone_ebola_data <-
readxl::read_xlsx("data-raw/pnas.1518587113.sd02.xlsx") |>
janitor::clean_names()

usethis::use_data(sierra_leone_ebola_data, overwrite = TRUE)
Binary file added data/sierra_leone_ebola_data.rda
Binary file not shown.
31 changes: 31 additions & 0 deletions man/ebola_outbreak_sierra_leone.Rd

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

15 changes: 15 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set.seed(101)

meanlog <- 1.8
sdlog <- 0.5
obs_time <- 25
sample_size <- 200

sim_obs <- simulate_gillespie() |>
simulate_secondary(
meanlog = meanlog,
sdlog = sdlog
) |>
observe_process() |>
filter_obs_by_obs_time(obs_time = obs_time) %>%
.[sample(seq_len(.N), sample_size, replace = FALSE)]

0 comments on commit 1cbaf82

Please sign in to comment.