rgx <- list(
fruit = "Apple|Banana",
vegetable = "Spinach|Kale"
)
test_that("matchit returns the expected results", {
x <- data.table::data.table(
ID = 1,
CODE = "Apple"
)
expect_equal(object = comorbidity:::.matchit(x = x, id = "ID", code = "CODE", regex = rgx)$fruit, expected = 1)
expect_equal(object = comorbidity:::.matchit(x = x, id = "ID", code = "CODE", regex = rgx)$vegetable, expected = 0)
#
x <- data.table::data.table(
ID = 1,
CODE = "Tomato"
)
expect_equal(object = comorbidity:::.matchit(x = x, id = "ID", code = "CODE", regex = rgx)$fruit, expected = 0)
expect_equal(object = comorbidity:::.matchit(x = x, id = "ID", code = "CODE", regex = rgx)$vegetable, expected = 0)
#
x <- data.table::data.table(
ID = 1,
CODE = "Kale"
)
expect_equal(object = comorbidity:::.matchit(x = x, id = "ID", code = "CODE", regex = rgx)$fruit, expected = 0)
expect_equal(object = comorbidity:::.matchit(x = x, id = "ID", code = "CODE", regex = rgx)$vegetable, expected = 1)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.