context("test-merge_to_episode")
data <- system.file("testdata", "testdata-merge_to_episode.rds", package = "hisreportr") %>%
readRDS()
out <- merge_to_episode(df_episode = data[[1]],
df_info = data[[2]],
key_var = id,
start_date = sdate,
eval_date = reg_date,
post_start = FALSE)
test_that("merged correctly", {
expect_equal(nrow(data[[1]]), nrow(out))
expect_true(is.data.frame(out))
expect_identical(unique(out[c("id", "sdate")]),
out[c("id", "sdate")])
expect_true("ch" %in% names(out))
expect_true(all(as.numeric(out$sdate - out$reg_date) >= 0,
na.rm = TRUE))
expect_true(all(is.na(out$ch[is.na(out$reg_date)])))
# search for any duplicated variables by searching for variable names
# ending with .x
expect_false(any(grepl("\\.x$", names(out))))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.