-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #48
- Loading branch information
Showing
3 changed files
with
123 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,106 @@ | ||
test_that("follow_up works", { | ||
data(survey, package = "MASS") | ||
survey1 <- survey[1:118, ] | ||
survey2 <- survey[119:nrow(survey), ] | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu <- follow_up(survey1, survey2, size_subset = 50, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
expect_s3_class(fu, "data.frame") | ||
}) | ||
|
||
test_that("follow_up2 works", { | ||
data(survey, package = "MASS") | ||
expect_error(follow_up2(survey, iterations = 10)) | ||
|
||
old_n <- 118 | ||
# old vs new | ||
survey$batch <- c(rep("old", old_n), rep(NA, nrow(survey) - old_n)) | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu1 <- follow_up2(survey, iterations = 10), | ||
"with the data."), | ||
"with the new samples"), | ||
"some problems with the new data."), | ||
"some problems with the old data.") | ||
expect_type(fu1, "character") | ||
# old vs new with confounding effects | ||
survey$batch <- ifelse(survey$Clap %in% "Right", "old", NA) | ||
expect_error( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
follow_up2(survey, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
||
# old with batches vs new | ||
bn <- batch_names(create_subset(old_n, 20)) | ||
survey$batch <- c(bn, rep(NA, nrow(survey) - old_n)) | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu3 <- follow_up2(survey, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
expect_type(fu3, "character") | ||
# old with batches and confounding effect vs new | ||
survey$batch <- ifelse(survey$Clap %in% "Right", "old", NA) | ||
bn <- batch_names(create_subset(sum(survey$Clap %in% "Right", na.rm = TRUE), 20)) | ||
survey$batch[survey$batch %in% "old"] <- bn | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu4 <- follow_up2(survey, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
expect_type(fu4, "character") | ||
}) | ||
|
||
|
||
test_that("valid_followup works", { | ||
data(survey, package = "MASS") | ||
survey1 <- survey[1:118, ] | ||
survey2 <- survey[119:nrow(survey), ] | ||
|
||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
out <- valid_followup(survey1, survey2) | ||
) | ||
) | ||
) | ||
) | ||
expect_false(out) | ||
survey$batch <- NA | ||
survey$batch[1:118] <- "old" | ||
|
||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
out <- valid_followup(all_data = survey) | ||
) | ||
) | ||
) | ||
) | ||
expect_false(out) | ||
}) | ||
test_that("follow_up works", { | ||
data(survey, package = "MASS") | ||
survey1 <- survey[1:118, ] | ||
survey2 <- survey[119:nrow(survey), ] | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu <- follow_up(survey1, survey2, size_subset = 50, iterations = 10, old_new = "batch2") | ||
) | ||
) | ||
) | ||
) | ||
expect_s3_class(fu, "data.frame") | ||
}) | ||
|
||
test_that("follow_up2 works", { | ||
data(survey, package = "MASS") | ||
expect_error(follow_up2(survey, iterations = 10)) | ||
|
||
old_n <- 118 | ||
# old vs new | ||
survey$batch <- c(rep("old", old_n), rep(NA, nrow(survey) - old_n)) | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu1 <- follow_up2(survey, iterations = 10), | ||
"with the data."), | ||
"with the new samples"), | ||
"some problems with the new data."), | ||
"some problems with the old data.") | ||
expect_type(fu1, "character") | ||
# old vs new with confounding effects | ||
survey$batch <- ifelse(survey$Clap %in% "Right", "old", NA) | ||
expect_error( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
follow_up2(survey, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
||
# old with batches vs new | ||
bn <- batch_names(create_subset(old_n, 20)) | ||
survey$batch <- c(bn, rep(NA, nrow(survey) - old_n)) | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu3 <- follow_up2(survey, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
expect_type(fu3, "character") | ||
# old with batches and confounding effect vs new | ||
survey$batch <- ifelse(survey$Clap %in% "Right", "old", NA) | ||
bn <- batch_names(create_subset(sum(survey$Clap %in% "Right", na.rm = TRUE), 20)) | ||
survey$batch[survey$batch %in% "old"] <- bn | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
fu4 <- follow_up2(survey, iterations = 10) | ||
) | ||
) | ||
) | ||
) | ||
expect_type(fu4, "character") | ||
}) | ||
|
||
|
||
test_that("valid_followup works", { | ||
data(survey, package = "MASS") | ||
survey1 <- survey[1:118, ] | ||
survey2 <- survey[119:nrow(survey), ] | ||
|
||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
out <- valid_followup(survey1, survey2) | ||
) | ||
) | ||
) | ||
) | ||
expect_false(out) | ||
survey$batch <- NA | ||
survey$batch[1:118] <- "old" | ||
|
||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
expect_warning( | ||
out <- valid_followup(all_data = survey) | ||
) | ||
) | ||
) | ||
) | ||
expect_false(out) | ||
}) |
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