-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…unit-tests Frequency table unit tests
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
dummy_data <- data.frame(year = rep(c(2020, 2021, 2022), each=2), | ||
heard_of_RAP = rep(c("Yes", "No"), times=3)) | ||
|
||
test_that("summarise_rap_awareness_over_time missing data is handled correctly", { | ||
|
||
dummy_data[1,2] <- NA | ||
|
||
got <- summarise_rap_awareness_over_time(dummy_data) | ||
|
||
expect_false(any(is.na.data.frame(got))) | ||
|
||
}) | ||
|
||
test_that("summarise_rap_awareness_over_time output is as expected", { | ||
|
||
got <- summarise_rap_awareness_over_time(dummy_data) | ||
|
||
expected <- data.frame(Var1 = factor(c("Yes", "Yes", "Yes"), | ||
levels = c("No", "Yes")), | ||
Var2 = factor(c("2020", "2021", "2022"), | ||
levels = c("2020", "2021", "2022")), | ||
Freq = c(1, 1, 1), | ||
n = c(2, 2, 2)) %>% | ||
get_ci(freq_col = 3, n_col = 4) | ||
|
||
expect_equal(got, expected) | ||
|
||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
dummy_data <- data.frame(CS_grade = c(NA, | ||
rep("Higher Executive Officer (or equivalent)", 10), | ||
rep("Senior Executive Officer (or equivalent)", 10), | ||
rep("Grade 7 (or equivalent)", 5), | ||
rep("Grade 6 (or equivalent)", 5)), | ||
coding_ability_change = c(NA, | ||
rep(c("Significantly worse", | ||
"Slightly worse", | ||
"No change", | ||
"Slightly better", | ||
"Significantly better"), | ||
times = 6))) | ||
|
||
test_that("summarise_cap_change_by_CS_grade missing data is handled correctly", { | ||
|
||
got <- summarise_cap_change_by_CS_grade(dummy_data) | ||
|
||
expect_false(any(is.na.data.frame(got))) | ||
|
||
}) | ||
|
||
test_that("summarise_cap_change_by_CS_grade output is as expected", { | ||
|
||
got <- summarise_cap_change_by_CS_grade(dummy_data) | ||
|
||
expected <- data.frame(CS_grade = factor(rep(c("Higher Executive Officer (or equivalent)", | ||
"Senior Executive Officer (or equivalent)", | ||
"Grade 6 and 7"), | ||
each = 5), | ||
levels = c("Higher Executive Officer (or equivalent)", | ||
"Senior Executive Officer (or equivalent)", | ||
"Grade 6 and 7")), | ||
coding_ability_change = factor(rep(c("Significantly worse", | ||
"Slightly worse", | ||
"No change", | ||
"Slightly better", | ||
"Significantly better"), 3), | ||
levels = c("Significantly worse", | ||
"Slightly worse", | ||
"No change", | ||
"Slightly better", | ||
"Significantly better")), | ||
n = c(0.20, 0.20, 0.20, 0.20, 0.20, | ||
0.20, 0.20, 0.20, 0.20, 0.20, | ||
0.20, 0.20, 0.20, 0.20, 0.20)) | ||
|
||
|
||
expect_equal(got, expected) | ||
|
||
|
||
}) |