Skip to content

Commit

Permalink
Merge pull request #101 from OxfordIHTM/dev
Browse files Browse the repository at this point in the history
add tests for cod_check_code_summary
  • Loading branch information
ernestguevarra authored Jul 3, 2024
2 parents e1e8b66 + 58ca46d commit 8072d1f
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
docs
inst/doc
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Imports:
tibble
Suggests:
covr,
knitr,
rmarkdown,
spelling,
testthat (>= 3.0.0)
Remotes:
Expand All @@ -41,3 +43,4 @@ RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
URL: https://github.com/OxfordIHTM/codeditr, http://oxford-ihtm.io/codeditr/
Config/testthat/edition: 3
VignetteBuilder: knitr
2 changes: 1 addition & 1 deletion R/cod_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @examples
#' cod_check_code(
#' cod_data_raw_example$code, version = "icd11",
#' sex = cod_data_raw_example$sex", age = cod_data_raw_example$age
#' sex = cod_data_raw_example$sex, age = cod_data_raw_example$age
#' ) |>
#' cod_check_code_summary()
#'
Expand Down
8 changes: 8 additions & 0 deletions man/cod_check_code_summary.Rd

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

30 changes: 30 additions & 0 deletions tests/testthat/test-cod_check_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,33 @@ test_that("cod_check_code outputs appropriate results", {
)
})


code <- c(sample(icd10_cod_neonate$code, size = 4),
sample(icd10_cod_child$code, size = 4))
sex <- rep(c(1, 1, 2, 1), 2)
age <- c(0, 0, 1, 5, 0, 10, 11, 9)

test_icd10_df <- data.frame(age, sex, code)

code <- c(sample(icd11_cod_neonate$code, size = 4),
sample(icd11_cod_child$code, size = 4))
sex <- rep(c(1, 1, 2, 1), 2)
age <- c(0, 0, 1, 5, 0, 10, 11, 9)

test_icd11_df <- data.frame(age, sex, code)

test_that("cod_check_code outputs appropriate age test results", {
expect_s3_class(
cod_check_code(
test_icd10_df$code, sex = test_icd10_df$sex, age = test_icd10_df$age
),
"tbl"
)

expect_s3_class(
cod_check_code(
test_icd11_df$code, sex = test_icd11_df$sex, age = test_icd11_df$age
),
"tbl"
)
})
17 changes: 17 additions & 0 deletions tests/testthat/test-cod_summary.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Tests for cod_check_code_summary ---------------------------------------------

test_summary_df <- cod_check_code(
cod_data_raw_example$code, version = "icd11",
sex = cod_data_raw_example$sex, age = cod_data_raw_example$age
)


testthat::test_that("cod_check_code_summary outputs appropriate results", {
expect_type(cod_check_code_summary(test_summary_df), "list")

expect_s3_class(
cod_check_code_summary(test_summary_df, simplify = TRUE), "tbl"
)
})


2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
21 changes: 21 additions & 0 deletions vignettes/codeditr.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "Implementing Cause-of-Death Data Checks with codeditr"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Implementing Cause-of-Death Data Checks with codeditr}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
library(codeditr)
```

The [World Health Organization](https://www.who.int/)'s [CoDEdit electronic tool](https://www.who.int/standards/classifications/classification-of-diseases/services/codedit-tool) is intended to help producers of cause-of-death statistics in strengthening their capacity to perform routine checks on their data. This package ports the original tool built using Microsoft Access into R. The aim is to leverage the utility and function of the original tool into a usable application program interface (API) that can be used for building more universal tools or for creating programmatic scientific workflows aimed at routine, automated, and large-scale monitoring of cause-of-death data.

0 comments on commit 8072d1f

Please sign in to comment.