Skip to content

Commit

Permalink
Merge branch 'main' into 864_fix_tt_at_path@main
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades authored Feb 24, 2025
2 parents 6904664 + 4b7f2fc commit 19a823d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rtables
Title: Reporting Tables
Version: 0.6.11.9005
Date: 2025-02-17
Version: 0.6.11.9006
Date: 2025-02-21
Authors@R: c(
person("Gabriel", "Becker", , "gabembecker@gmail.com", role = "aut",
comment = "Original creator of the package"),
Expand Down
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## rtables 0.6.11.9005
## rtables 0.6.11.9006

### New Features
* Added `stat_string` to `as_result_df(make_ard = TRUE)` to preserve the original string representation of the statistics.
Expand All @@ -8,7 +8,8 @@
* Fixed issue with `split_cols_by_multivar()` when having more than one value. Now `as_result_df(make_ard = TRUE)` adds a predefined split name for each of the `multivar` splits.
* Fixed a bug with `tt_at_path()` caused by the impossibility to solve multiple branches with identical names.
* Fixed bug happening when format functions were changing the number of printed values. Now `as_result_df(make_ard = TRUE)` uses the cell values for `stat_strings` for these exceptions.

* Fixed bug in `[<-` causing information to be stripped from other cells if a new `rcell` is set within a table row.

## rtables 0.6.11

### New Features
Expand Down
16 changes: 11 additions & 5 deletions R/tt_pos_and_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ recursive_replace <- function(tab, path, value) { ## incontent = FALSE, rows = N
## newkid[rows, cols] = value
## }
## }
return(newkid)
newkid
} else if (path[[1]] == "@content") {
ctb <- content_table(tab)
ctb <- recursive_replace(ctb,
Expand Down Expand Up @@ -487,7 +487,7 @@ setMethod(
#' tbl[, -1]
#'
#' # Values can be reassigned
#' tbl[2, 1] <- rcell(999)
#' tbl[4, 2] <- rcell(999, format = "xx.x")
#' tbl[2, ] <- list(rrow("FFF", 888, 666, 777))
#' tbl[6, ] <- list(-111, -222, -333)
#' tbl
Expand Down Expand Up @@ -599,9 +599,15 @@ setMethod(
curkid <- nxtval
value <- value[-1]
} else {
rvs <- row_values(curkid)
rvs[j] <- value[seq_along(j)]
row_values(curkid) <- rvs
if (is(nxtval, "CellValue")) {
rcs <- row_cells(curkid)
rcs[j] <- value[seq_along(j)]
row_cells(curkid) <- rcs
} else {
rvs <- row_values(curkid)
rvs[j] <- value[seq_along(j)]
row_values(curkid) <- rvs
}
value <- value[-(seq_along(j))]
}
kids[[pos]] <- curkid
Expand Down
2 changes: 1 addition & 1 deletion man/brackets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rtables.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 4d2c3c80-3618-40eb-b805-a291cb9acbf6

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
24 changes: 23 additions & 1 deletion tests/testthat/test-subset-access.R
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,30 @@ test_that("setters work ok", {
cell_values(tbl4)[["U.AGE.mean"]],
list(5, 7, 8)
)
})

tbl5 <- tbl
tbl5[4, 1] <- rcell(999, format = "xx.xx")
tbl5[5, 2] <- list(c(3, 0.25))
tbl5[5, 3] <- rcell(NA, format_na_str = "<NA>")
tbl5[6, ] <- list(-111, -222, -333)
matform5 <- matrix_form(tbl5)
expect_identical(
c("mean", "999.00", "32.1", "34.2794117647059"),
mf_strings(matform5)[5, ]
)
expect_identical(
c("U", "0 (0.0%)", "3 (25.0%)", "<NA>"),
mf_strings(matform5)[6, ]
)
expect_identical(
c("mean", "-111", "-222", "-333"),
mf_strings(matform5)[7, ]
)
expect_identical(
c("", "xx.xx", "xx", "xx"),
mf_formats(matform5)[5, ]
)
})

test_that("cell_values and value_at work on row objects", {
tbl <- basic_table() %>%
Expand Down

0 comments on commit 19a823d

Please sign in to comment.