Skip to content

Commit e761544

Browse files
authored
Merge branch 'main' into feat/list-needed-vars
2 parents 33df9fb + 0d68b77 commit e761544

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

DESCRIPTION

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Type: Package
22
Package: osdc
3-
Title: Open Source Diabetes Classifier for Danish Registers.
3+
Title: Open Source Diabetes Classifier (OSCD) for Danish Registers
44
Version: 0.0.1.9000
55
Authors@R: c(
66
person(
@@ -51,8 +51,6 @@ Imports:
5151
purrr,
5252
rlang
5353
Suggests:
54-
furrr,
55-
DiagrammeR,
5654
knitr,
5755
rmarkdown,
5856
testthat (>= 3.0.0),

R/verify-variables.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#' verify_required_variables(example_bef_data, "bef")
2121
verify_required_variables <- function(data, register) {
2222
checkmate::assert_choice(register, get_register_abbrev())
23-
23+
24+
# TODO: Consider using/looking into rlang::try_fetch() to provide contextual error messages.
2425
expected_variables <- get_required_variables(register)
2526

26-
actual_variables <- names(data)
27-
28-
# TODO: Consider using/looking into rlang::try_fetch() to provide contextual error messages.
27+
actual_variables <- colnames(data)
28+
2929
checkmate::check_names(
3030
x = actual_variables,
3131
must.include = expected_variables

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
<!-- badges: start -->
44

55
[![R-CMD-check](https://github.com/steno-aarhus/osdc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/steno-aarhus/osdc/actions/workflows/R-CMD-check.yaml)
6-
6+
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
77
<!-- badges: end -->
88

99
The goal of *osdc* is to expose an algorithm for classifying diabetes
1010
within the Danish registers that can be accessible as an R package. The
11-
algorithm has been developed at Steno Diabetes Center Aarhus that is
11+
algorithm that has been developed at Steno Diabetes Center Aarhus is
1212
flexible and convenient to use, and validated in terms of accuracy.
1313
While there are a few algorithms used throughout Denmark for Danish
1414
register research, they are usually textual descriptions of how to do
1515
it, rather than code-based descriptions (e.g. the [Register of Selected
1616
Chronic
1717
Diseases](https://www.esundhed.dk/-/media/Files/Publikationer/Emner/Operationer-og-diagnoser/Udvalgte-kroniske-sygdomme-svaere-psykiske-lidelser/Algoritmer-for-Udvalgte-Kroniske-Sygdomme-og-svre-psykiske-lidelser-RUKS-2022.ashx).
1818

19-
In this project, we aim to make it easier and more explicit in
20-
classifying type 1 and type 2 diabetes within a Danish register context.
19+
In this project, we aim to make it easier and more explicit to
20+
classify type 1 and type 2 diabetes within a Danish register context.
2121
The original implementation of the algorithm is validated in a
2222
peer-reviewed publication [here](https://doi.org/10.2147/clep.s407019),
2323
but we expect to make tweaks to the algorithm over time. Any changes

man/hello.Rd

-12
This file was deleted.
+32-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
library(tibble)
22

3-
test_that("the correct abbreviation for the register is used", {
4-
bef_complete <- tibble(pnr = 1, koen = 1, foed_dato = 1)
3+
bef_complete <- tibble::tibble(pnr = 1, koen = 1, foed_dato = 1)
54

5+
test_that("the correct abbreviation for the register is used", {
66
# When incorrect register abbreviation is given
77
expect_error(verify_required_variables(bef_complete, "bef1"))
88
# When correct abbreviation is given
@@ -11,7 +11,6 @@ test_that("the correct abbreviation for the register is used", {
1111

1212
test_that("the required variables are present in the dataset", {
1313
# Expected
14-
bef_complete <- tibble(pnr = 1, koen = 1, foed_dato = 1)
1514
bef_complete_extra <- tibble(pnr = 1, koen = 1, foed_dato = 1, something = 1)
1615
bef_incomplete <- tibble(pnr = 1, koen = 1)
1716

@@ -22,5 +21,34 @@ test_that("the required variables are present in the dataset", {
2221
expect_true(verify_required_variables(bef_complete_extra, "bef"))
2322

2423
# When it is a character output, it is a fail
25-
expect_character(verify_required_variables(bef_incomplete, "bef"))
24+
expect_type(verify_required_variables(bef_incomplete, "bef"), "character")
25+
})
26+
27+
28+
test_that("verification works for DuckDB Database", {
29+
actual <- arrow::to_duckdb(bef_complete) |>
30+
verify_required_variables("bef")
31+
32+
expect_true(actual)
33+
})
34+
35+
test_that("verification works for Arrow Tables (from Parquet)", {
36+
actual <- arrow::as_arrow_table(bef_complete) |>
37+
verify_required_variables("bef")
38+
39+
expect_true(actual)
40+
})
41+
42+
test_that("verification works for data.frame", {
43+
actual <- as.data.frame(bef_complete) |>
44+
verify_required_variables("bef")
45+
46+
expect_true(actual)
47+
})
48+
49+
test_that("verification works for data.table", {
50+
actual <- data.table::as.data.table(bef_complete) |>
51+
verify_required_variables("bef")
52+
53+
expect_true(actual)
2654
})

0 commit comments

Comments
 (0)