Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 40: Add example test data #41

Merged
merged 17 commits into from
May 16, 2024
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
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 @@ -30,3 +30,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)]