-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refac: replaced 'censore' by 'censor'. This misspelling had propagate…
…d throughout all the new functions
- Loading branch information
1 parent
e68e75c
commit 47d70e2
Showing
6 changed files
with
79 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#### Tests for censor_match() | ||
|
||
## prepare data | ||
data("cohortdata") | ||
start_cohort <- as.Date("2044-01-01") | ||
end_cohort <- as.Date("2044-12-31") | ||
|
||
# sample cohort to make tests faster - take a bigger sample | ||
sample_size <- 5000 | ||
sample_indices <- sample(nrow(cohortdata), sample_size) | ||
sample_cohort <- cohortdata[sample_indices, ] | ||
rownames(sample_cohort) <- NULL | ||
|
||
# assign vaccination status | ||
sample_cohort$vaccine_status <- set_status( | ||
data = sample_cohort, | ||
col_names = "vaccine_date_2", | ||
status = c("v", "u") | ||
) | ||
# match cohort | ||
matched_cohort <- match_cohort(data = sample_cohort, | ||
status_vacc_col = "vaccine_status", | ||
exact = "sex" | ||
) | ||
# add column with censoring date for match | ||
matched_cohort$censoring_date <- censor_match( | ||
data = matched_cohort, | ||
censoring_date_col = "death_other_causes" | ||
) | ||
|
||
# snapshot test basic expectations | ||
test_that("`censor_match`: basic expectations", { | ||
# expect date | ||
expect_vector( | ||
matched_cohort$censoring_date, | ||
ptype = as.Date("2045-01-01") | ||
) | ||
# filter registers with censoring date informed | ||
censored_original <- | ||
matched_cohort[!is.na(matched_cohort$death_other_causes), ] | ||
# filter registers with censoring date created after matching | ||
censored_match <- | ||
matched_cohort[!is.na(matched_cohort$censoring_date), ] | ||
|
||
# All the subclass IDs in censored_match must be contained in | ||
# censored_original | ||
expect_true( | ||
all(censored_match$subclass %in% censored_original$subclass) | ||
) | ||
}) | ||
|
||
test_that("`censor_match`: take minimum censoring date", { | ||
censored_twodates <- | ||
matched_cohort[!is.na(matched_cohort$censoring_date) & | ||
!is.na(matched_cohort$death_other_causes), | ||
] | ||
|
||
expect_true( | ||
all( | ||
censored_twodates$censoring_date <= censored_twodates$death_other_causes | ||
) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#### Tests for censore_match() | ||
#### Tests for censor_match() | ||
|
||
## prepare data | ||
data("cohortdata") | ||
|