Skip to content

Commit

Permalink
Fix column name misalignment bug in as_result_df
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed Nov 27, 2023
1 parent 6329f92 commit eabf02a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Bug Fixes
* Fixed a bug that was failing when wrapping and section dividers were used at the same time.
* Fixed a bug in `as_result_df` causing misalignment of column names.

### Miscellaneous
* Applied `styler` and resolved package lint. Changed default indentation from 4 spaces to 2.
Expand Down
3 changes: 2 additions & 1 deletion R/tt_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ do_data_row <- function(rdfrow, maxlen) {
if (pthlen %% 2 == 1) {
pth <- pth[-1 * (pthlen - 2)]
}
pthlen_new <- length(pth)
c(
as.list(pth[seq_len(pthlen - 2)]),
as.list(pth[seq_len(pthlen_new - 2)]),
replicate(maxlen - pthlen, list(NA_character_)),
as.list(tail(pth, 2)),
list(row_num = rdfrow$abs_rownumber, content = FALSE, node_class = rdfrow$node_class)
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-result_data_frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,20 @@ test_that("Result Data Frame generation works v0", {
result_df3 <- as_result_df(tbl3, spec_version)

expect_identical(nrow(result_df3), 1L)

## test labels when no row splits
lyt4 <- basic_table() %>%
split_cols_by("ARM") %>%
analyze(c("AGE", "SEX"))

tbl4 <- build_table(lyt4, DM)
result_df4 <- as_result_df(tbl4)

expect_identical(
names(result_df4),
c(
"avar_name", "row_name", "row_num", "is_group_summary",
"node_class", "A: Drug X", "B: Placebo", "C: Combination"
)
)
})

0 comments on commit eabf02a

Please sign in to comment.