Skip to content

Commit

Permalink
test + news + general fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Nov 29, 2023
1 parent fb67b31 commit 3cdd669
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
### 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.
* 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.

### Miscellaneous
* Applied `styler` and resolved package lint. Changed default indentation from 4 spaces to 2.
Expand Down
2 changes: 1 addition & 1 deletion R/tt_paginate.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ setMethod(
colwidths = colwidths,
sibpos = sibpos,
nsibs = nsibs,
pth = c(path, obj_name(tt)),
pth = c(path, unname(obj_name(tt))),
repext = repr_ext,
repind = repr_inds,
indent = indent,
Expand Down
3 changes: 2 additions & 1 deletion R/tt_pos_and_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ setMethod(
length(path) > 0,
!anyNA(path)
)
if (path[1] == "root" & obj_name(tt) != "root") {

if (path[1] == "root" && obj_name(tt) != "root") {
path <- path[-1]
}
## handle pathing that hits the root split by name
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-subset-access.R
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,21 @@ test_that("bracket methods all work", {
tbl[, c(TRUE, FALSE, FALSE, TRUE, FALSE, TRUE)]
)
})

test_that("tt_at_path and cell_values work with values even if they differ in naming", {
# see issue #794
tbl <- basic_table() %>%
split_cols_by(var = "ARM", split_label = "asdar") %>%
# split_rows_by(var = "SEX") %>%
add_colcounts() %>%
analyze("AGE", afun = function(x) {
out_list <- list(a = mean(x), b = 3)
labs <- c("argh", "argh2")
attr(out_list[[1]], "label") <- "aa"
attr(out_list[[2]], "label") <- "aa2"
in_rows(.list = out_list, .labels = labs, .names = labs)
},
show_labels = "visible", table_names = "nope") %>%
build_table(df = DM)
expect_silent(tt_at_path(tbl, row_paths(tbl)[[2]]))
})

0 comments on commit 3cdd669

Please sign in to comment.