Skip to content

Commit

Permalink
Fix as_result_df bug for small tables (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua authored Dec 6, 2023
1 parent 82d78c1 commit 8f9f1fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fixed a bug in `as_result_df` causing misalignment of column names.
* Fixed a bug that was not allowing path indexing as `row_paths()` was giving a different path due to it being made of
named values.
* Fixed a bug in `as_result_df` when called on tables with less than 3 rows.

### Miscellaneous
* Applied `styler` and resolved package lint. Changed default indentation from 4 spaces to 2.
Expand Down
1 change: 1 addition & 0 deletions R/tt_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ do_data_row <- function(rdfrow, maxlen) {
pth <- pth[-1 * (pthlen - 2)]
}
pthlen_new <- length(pth)
if (maxlen == 1) pthlen_new <- 3
c(
as.list(pth[seq_len(pthlen_new - 2)]),
replicate(maxlen - pthlen, list(NA_character_)),
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 @@ -112,4 +112,20 @@ test_that("as_result_df works with visual output (as_viewer)", {

tbl <- build_table(lyt, ex_adsl)
expect_equal(as_result_df(tbl, simplify = TRUE, as_viewer = TRUE)[2, 2][[1]], c(24, 46))

# Test for tables with less than 3 rows
tbl <- rtable(
header = rheader(rrow("", "c1", "c2")),
rrow("row 1", 1, c(.8, 1.2))
)
expect_equal(
as_result_df(tbl)[, 1:5],
data.frame(
"avar_name" = "row 1",
"row_name" = "row 1",
"row_num" = 1,
"is_group_summary" = FALSE,
"node_class" = "DataRow"
)
)
})

0 comments on commit 8f9f1fa

Please sign in to comment.