Skip to content

Commit

Permalink
added comment, test and NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
kpagacz committed Nov 22, 2024
1 parent ed93699 commit 7204055
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

### Bug Fixes
* Fixed bug that was keeping indentation space characters in top left information when making a `flextable` from a `TableTree` object.
* Fixed bug in `analyze` that was causing an error when passing a single `NA` value to the
`var_labels` parameter.

## rtables 0.6.10

Expand Down
3 changes: 3 additions & 0 deletions R/colby_constructors.R
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@ analyze <- function(lyt,
section_div = NA_character_) {
show_labels <- match.arg(show_labels)
subafun <- substitute(afun)
# R treats a single NA value as a logical atomic. The below
# maps all the NAs in `var_labels` to NA_character_ required by `Split`
# and avoids the error when `var_labels` is just c(NA).
var_labels <- vapply(var_labels, function(label) ifelse(is.na(label), NA_character_, label), character(1))
if (
is.name(subafun) &&
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-colby_constructors.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test_that("analyze's var_labels accepts a vector of length 1 consisting of a single NA", {
testthat::expect_no_error(
basic_table() %>%
split_cols_by("ARM") %>%
analyze("AGE", var_labels = c(AGE = NA))
)
})

0 comments on commit 7204055

Please sign in to comment.