Skip to content

Commit

Permalink
Regression test for fix of #173
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbecker committed Mar 15, 2021
1 parent 7b3a685 commit 6629a3d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/testthat/test-regressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,28 @@ test_that("inclNAs with empty factor levels behaves", {
build_table(dfdm)
expect_identical(tbl,tbl2)
})


## #173
test_that("column labeling works correctly when value label var is a factor", {

ex_adsl$ARMLAB <- factor(ex_adsl$ARM,
labels = c("Drug X", "Placebo", "Combination"))
lyt_orig <- basic_table() %>%
split_cols_by("ARM") %>%
analyze(c("AGE", "BMRKR2"))
tbl_orig <- build_table(lyt_orig, ex_adsl)

lyt_lab <- basic_table() %>%
split_cols_by("ARM", labels_var = "ARMLAB") %>%
analyze(c("AGE", "BMRKR2"))
tbl_lab <- build_table(lyt_lab, ex_adsl)

tbl_orig
tbl_lab # wrong labeling here
expect_identical(names(tbl_lab),
names(tbl_orig))
str <- matrix_form(tbl_lab)$strings
expect_identical(as.vector(str[1,]),
c("", "Drug X", "Placebo", "Combination"))
})

0 comments on commit 6629a3d

Please sign in to comment.