From d21b23a3d7df54fae2caa6d653583e31433cbf9f Mon Sep 17 00:00:00 2001 From: munoztd0 Date: Mon, 29 Jun 2026 10:23:32 +0000 Subject: [PATCH 1/5] EXTERNAL: rtables exports --- NAMESPACE | 6 +++ NEWS.md | 2 + R/tree_accessors.R | 65 +++++++++++++++++++++++++++++---- man/splv_extra.Rd | 47 ++++++++++++++++++++++++ man/value_expr.Rd | 34 +++++++++++++++++ tests/testthat/test-accessors.R | 28 ++++++++++++++ 6 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 man/splv_extra.Rd create mode 100644 man/value_expr.Rd diff --git a/NAMESPACE b/NAMESPACE index f92c9b0742..3f91bd9b35 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,6 +26,7 @@ export("ref_symbol<-") export("row_footnotes<-") export("section_div<-") export("section_div_at_path<-") +export("splv_extra<-") export("top_left<-") export("top_level_section_div<-") export("tree_children<-") @@ -177,6 +178,7 @@ export(split_rows_by_cutfun) export(split_rows_by_cuts) export(split_rows_by_multivar) export(split_rows_by_quartiles) +export(splv_extra) export(str) export(subset_cols) export(summarize_row_groups) @@ -197,6 +199,7 @@ export(tt_row_path_exists) export(update_ref_indexing) export(validate_table_struct) export(value_at) +export(value_expr) export(value_formats) export(value_names) export(vars_in_layout) @@ -239,6 +242,7 @@ exportMethods("ref_index<-") exportMethods("ref_symbol<-") exportMethods("row_footnotes<-") exportMethods("row_values<-") +exportMethods("splv_extra<-") exportMethods("subtitles<-") exportMethods("table_inset<-") exportMethods("top_left<-") @@ -296,6 +300,7 @@ exportMethods(row_footnotes) exportMethods(row_values) exportMethods(simple_analysis) exportMethods(spl_variable) +exportMethods(splv_extra) exportMethods(str) exportMethods(subset_cols) exportMethods(subtitles) @@ -306,6 +311,7 @@ exportMethods(top_left) exportMethods(tree_children) exportMethods(tt_at_path) exportMethods(value_at) +exportMethods(value_expr) import(formatters) import(methods) importFrom(formatters,do_forced_paginate) diff --git a/NEWS.md b/NEWS.md index 405f057316..56c47a80c7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,8 @@ ### New Features * Added `restrict_facets` function factory for use with `make_split_fun` * Exportd previously internal `make_subset_expr` for use when constructing custom splitting behavior + * Exported previously internal `splv_extra` and `splv_extra<-` accessors for getting and setting child-specific extra arguments on `SplitValue` objects. + * Exported previously internal `value_expr` accessor for retrieving the subsetting expression from a `SplitValue` or `ValueWrapper` object. ## rtables 0.6.15 diff --git a/R/tree_accessors.R b/R/tree_accessors.R index 70efe6f2ad..0c234d4130 100644 --- a/R/tree_accessors.R +++ b/R/tree_accessors.R @@ -1843,11 +1843,32 @@ setMethod( #' @rdname int_methods setMethod("value_labels", "MultiVarSplit", function(obj) obj@var_labels) -#' @rdname int_methods +#' Retrieve the subset expression from a split value +#' +#' Returns the subsetting expression associated with a `SplitValue` (or +#' `ValueWrapper`) object, or `NULL` for objects without one. This expression +#' is used internally to subset data when tabulating. +#' +#' @param obj (`ValueWrapper` or `ANY`)\cr a split value object, typically a +#' `SplitValue` constructed by [SplitValue()]. Any other object returns +#' `NULL`. +#' +#' @return An `expression` object, or `NULL`. +#' +#' @examples +#' sv <- SplitValue("A", sub_expr = expression(ARM == "A")) +#' value_expr(sv) +#' +#' value_expr("not a SplitValue") # NULL +#' +#' @export +#' @rdname value_expr setGeneric("value_expr", function(obj) standardGeneric("value_expr")) -#' @rdname int_methods +#' @exportMethod value_expr +#' @rdname value_expr setMethod("value_expr", "ValueWrapper", function(obj) obj@subset_expression) -#' @rdname int_methods +#' @exportMethod value_expr +#' @rdname value_expr setMethod("value_expr", "ANY", function(obj) NULL) ## no setters for now, we'll see about that. @@ -1875,21 +1896,51 @@ setMethod("spl_varlabels<-", "MultiVarSplit", function(object, value) { ## to *all the chidlren*, ## while splv_extra is for *child-specific* extra arguments, ## associated with specific values of the split -#' @rdname int_methods + +#' Access or set child-specific extra arguments on a split value +#' +#' `splv_extra` retrieves the named list of *child-specific* extra arguments +#' stored on a `SplitValue` object. These arguments are forwarded to the +#' analysis or content function only for the facet represented by that +#' particular split value, making them distinct from [split_exargs()] which +#' applies to *all* children of a split. +#' +#' @param obj (`SplitValue`)\cr a split value object, typically produced by +#' [SplitValue()] or as a result of a splitting operation. +#' @param value (`list`)\cr named list of extra arguments to store on `obj`. +#' +#' @return +#' * `splv_extra` returns the current `list` of child-specific extra args. +#' * `splv_extra<-` returns `obj` with the extra arguments replaced. +#' +#' @seealso [split_exargs()] for split-level (all-children) extra arguments. +#' +#' @examples +#' sv <- SplitValue("A", extr = list(my_arg = 1)) +#' splv_extra(sv) +#' +#' splv_extra(sv) <- list(my_arg = 99) +#' splv_extra(sv) +#' +#' @export +#' @rdname splv_extra setGeneric("splv_extra", function(obj) standardGeneric("splv_extra")) -#' @rdname int_methods +#' @exportMethod splv_extra +#' @rdname splv_extra setMethod( "splv_extra", "SplitValue", function(obj) obj@extra ) -#' @rdname int_methods +#' @export +#' @rdname splv_extra setGeneric( "splv_extra<-", function(obj, value) standardGeneric("splv_extra<-") ) -#' @rdname int_methods +#' @exportMethod splv_extra<- +#' @rdname splv_extra setMethod( "splv_extra<-", "SplitValue", function(obj, value) { diff --git a/man/splv_extra.Rd b/man/splv_extra.Rd new file mode 100644 index 0000000000..7a6e05fe3e --- /dev/null +++ b/man/splv_extra.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree_accessors.R +\name{splv_extra} +\alias{splv_extra} +\alias{splv_extra,SplitValue-method} +\alias{splv_extra<-} +\alias{splv_extra<-,SplitValue-method} +\title{Access or set child-specific extra arguments on a split value} +\usage{ +splv_extra(obj) + +\S4method{splv_extra}{SplitValue}(obj) + +splv_extra(obj) <- value + +\S4method{splv_extra}{SplitValue}(obj) <- value +} +\arguments{ +\item{obj}{(\code{SplitValue})\cr a split value object, typically produced by +\code{\link[=SplitValue]{SplitValue()}} or as a result of a splitting operation.} + +\item{value}{(\code{list})\cr named list of extra arguments to store on \code{obj}.} +} +\value{ +\itemize{ +\item \code{splv_extra} returns the current \code{list} of child-specific extra args. +\item \verb{splv_extra<-} returns \code{obj} with the extra arguments replaced. +} +} +\description{ +\code{splv_extra} retrieves the named list of \emph{child-specific} extra arguments +stored on a \code{SplitValue} object. These arguments are forwarded to the +analysis or content function only for the facet represented by that +particular split value, making them distinct from \code{\link[=split_exargs]{split_exargs()}} which +applies to \emph{all} children of a split. +} +\examples{ +sv <- SplitValue("A", extr = list(my_arg = 1)) +splv_extra(sv) + +splv_extra(sv) <- list(my_arg = 99) +splv_extra(sv) + +} +\seealso{ +\code{\link[=split_exargs]{split_exargs()}} for split-level (all-children) extra arguments. +} diff --git a/man/value_expr.Rd b/man/value_expr.Rd new file mode 100644 index 0000000000..6cbd1857c9 --- /dev/null +++ b/man/value_expr.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree_accessors.R +\name{value_expr} +\alias{value_expr} +\alias{value_expr,ValueWrapper-method} +\alias{value_expr,ANY-method} +\title{Retrieve the subset expression from a split value} +\usage{ +value_expr(obj) + +\S4method{value_expr}{ValueWrapper}(obj) + +\S4method{value_expr}{ANY}(obj) +} +\arguments{ +\item{obj}{(\code{ValueWrapper} or \code{ANY})\cr a split value object, typically a +\code{SplitValue} constructed by \code{\link[=SplitValue]{SplitValue()}}. Any other object returns +\code{NULL}.} +} +\value{ +An \code{expression} object, or \code{NULL}. +} +\description{ +Returns the subsetting expression associated with a \code{SplitValue} (or +\code{ValueWrapper}) object, or \code{NULL} for objects without one. This expression +is used internally to subset data when tabulating. +} +\examples{ +sv <- SplitValue("A", sub_expr = expression(ARM == "A")) +value_expr(sv) + +value_expr("not a SplitValue") # NULL + +} diff --git a/tests/testthat/test-accessors.R b/tests/testthat/test-accessors.R index ed45d6ea12..64d0be6670 100644 --- a/tests/testthat/test-accessors.R +++ b/tests/testthat/test-accessors.R @@ -628,3 +628,31 @@ test_that("top_level_section_div works", { top_lev_div_str <- strsplit(toString(tbl), "\n")[[1]][7] expect_true(check_pattern(top_lev_div_str, "=", nchar(top_lev_div_str))) }) + +test_that("splv_extra getter and setter work", { + sv <- SplitValue("A", extr = list(foo = 1L)) + + expect_identical(splv_extra(sv), list(foo = 1L)) + + splv_extra(sv) <- list(foo = 99L, bar = "x") + expect_identical(splv_extra(sv), list(foo = 99L, bar = "x")) + + sv_bare <- SplitValue("B") + expect_identical(splv_extra(sv_bare), list()) + + sv2 <- SplitValue(sv, extr = list(baz = TRUE)) + expect_identical(splv_extra(sv2), list(foo = 99L, bar = "x", baz = TRUE)) +}) + +test_that("value_expr returns subset expression or NULL", { + sv_no_expr <- SplitValue("X") + expect_null(value_expr(sv_no_expr)) + + expr <- expression(ARM == "A") + sv_with_expr <- SplitValue("A", sub_expr = expr) + expect_identical(value_expr(sv_with_expr), expr) + + expect_null(value_expr("not a SplitValue")) + expect_null(value_expr(42L)) + expect_null(value_expr(list())) +}) From c54b65845cd12f75fcbd4e258ae06857fa9e90d5 Mon Sep 17 00:00:00 2001 From: munoztd0 Date: Wed, 1 Jul 2026 08:49:07 +0000 Subject: [PATCH 2/5] fix: export SplitValue, redocument and fix typo --- NAMESPACE | 1 + NEWS.md | 2 +- R/00tabletrees.R | 24 ++++++++++++++++++++++++ man/SplitValue.Rd | 37 +++++++++++++++++++++++++++++++++++++ man/int_methods.Rd | 21 --------------------- 5 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 man/SplitValue.Rd diff --git a/NAMESPACE b/NAMESPACE index 3f91bd9b35..70c51901fc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -44,6 +44,7 @@ export(InstantiatedColumnInfo) export(LabelRow) export(ManualSplit) export(MultiVarSplit) +export(SplitValue) export(TableTree) export(VarDynCutSplit) export(VarLevWBaselineSplit) diff --git a/NEWS.md b/NEWS.md index 56c47a80c7..51e5d620a7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ ### New Features * Added `restrict_facets` function factory for use with `make_split_fun` - * Exportd previously internal `make_subset_expr` for use when constructing custom splitting behavior + * Exported previously internal `make_subset_expr` for use when constructing custom splitting behavior * Exported previously internal `splv_extra` and `splv_extra<-` accessors for getting and setting child-specific extra arguments on `SplitValue` objects. * Exported previously internal `value_expr` accessor for retrieving the subsetting expression from a `SplitValue` or `ValueWrapper` object. diff --git a/R/00tabletrees.R b/R/00tabletrees.R index a3493ee5e6..b07ad08509 100644 --- a/R/00tabletrees.R +++ b/R/00tabletrees.R @@ -102,6 +102,30 @@ setClass("SplitValue", representation(extra = "list") ) +#' Construct a `SplitValue` object +#' +#' Creates a `SplitValue` object representing a single facet value produced +#' by a splitting operation, optionally carrying a custom subsetting expression +#' and child-specific extra arguments. +#' +#' @param val (`ANY`)\cr the raw value for this split facet. +#' @param extr (`list`)\cr named list of child-specific extra arguments to +#' forward to the analysis or content function for this facet. +#' @param label (`character(1)`)\cr display label. Defaults to `val`. +#' @param sub_expr (`expression` or `NULL`)\cr optional subsetting expression. +#' When `NULL` (default) the expression is derived automatically from `val` +#' during tabulation. +#' +#' @return A `SplitValue` object. +#' +#' @seealso [splv_extra()], [value_expr()] +#' +#' @examples +#' sv <- SplitValue("A", sub_expr = expression(ARM == "A")) +#' value_expr(sv) +#' splv_extra(sv) +#' +#' @export SplitValue <- function(val, extr = list(), label = val, sub_expr = NULL) { if (is(val, "SplitValue")) { if (length(splv_extra(val)) > 0) { diff --git a/man/SplitValue.Rd b/man/SplitValue.Rd new file mode 100644 index 0000000000..310686f905 --- /dev/null +++ b/man/SplitValue.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/00tabletrees.R +\name{SplitValue} +\alias{SplitValue} +\title{Construct a \code{SplitValue} object} +\usage{ +SplitValue(val, extr = list(), label = val, sub_expr = NULL) +} +\arguments{ +\item{val}{(\code{ANY})\cr the raw value for this split facet.} + +\item{extr}{(\code{list})\cr named list of child-specific extra arguments to +forward to the analysis or content function for this facet.} + +\item{label}{(\code{character(1)})\cr display label. Defaults to \code{val}.} + +\item{sub_expr}{(\code{expression} or \code{NULL})\cr optional subsetting expression. +When \code{NULL} (default) the expression is derived automatically from \code{val} +during tabulation.} +} +\value{ +A \code{SplitValue} object. +} +\description{ +Creates a \code{SplitValue} object representing a single facet value produced +by a splitting operation, optionally carrying a custom subsetting expression +and child-specific extra arguments. +} +\examples{ +sv <- SplitValue("A", sub_expr = expression(ARM == "A")) +value_expr(sv) +splv_extra(sv) + +} +\seealso{ +\code{\link[=splv_extra]{splv_extra()}}, \code{\link[=value_expr]{value_expr()}} +} diff --git a/man/int_methods.Rd b/man/int_methods.Rd index 31bad1aec2..eed80b0d9c 100644 --- a/man/int_methods.Rd +++ b/man/int_methods.Rd @@ -259,17 +259,10 @@ \alias{value_labels,ValueWrapper-method} \alias{value_labels,LevelComboSplitValue-method} \alias{value_labels,MultiVarSplit-method} -\alias{value_expr} -\alias{value_expr,ValueWrapper-method} -\alias{value_expr,ANY-method} \alias{spl_varlabels} \alias{spl_varlabels,MultiVarSplit-method} \alias{spl_varlabels<-} \alias{spl_varlabels<-,MultiVarSplit-method} -\alias{splv_extra} -\alias{splv_extra,SplitValue-method} -\alias{splv_extra<-} -\alias{splv_extra<-,SplitValue-method} \alias{split_exargs} \alias{split_exargs,Split-method} \alias{split_exargs<-} @@ -948,12 +941,6 @@ value_labels(obj) \S4method{value_labels}{MultiVarSplit}(obj) -value_expr(obj) - -\S4method{value_expr}{ValueWrapper}(obj) - -\S4method{value_expr}{ANY}(obj) - spl_varlabels(obj) \S4method{spl_varlabels}{MultiVarSplit}(obj) @@ -962,14 +949,6 @@ spl_varlabels(object) <- value \S4method{spl_varlabels}{MultiVarSplit}(object) <- value -splv_extra(obj) - -\S4method{splv_extra}{SplitValue}(obj) - -splv_extra(obj) <- value - -\S4method{splv_extra}{SplitValue}(obj) <- value - split_exargs(obj) \S4method{split_exargs}{Split}(obj) From 402d77701b55b21d63d02feaad9d9d5e95af63ff Mon Sep 17 00:00:00 2001 From: munoztd0 Date: Wed, 1 Jul 2026 12:19:13 +0000 Subject: [PATCH 3/5] update wordlist --- inst/WORDLIST | 90 +++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/inst/WORDLIST b/inst/WORDLIST index 632e83e430..101cfef1fd 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,25 +1,55 @@ -Abinaya AE AEs -afun -afuns -amongst ARD -ard ARDs -biomarker BMEASIFL -Bov -Bov +Bové +CRAN's Carreras -charset Cheatsheet Chohan +FFFL +Godwin +Heng +Hoffmann +Kelkhoff +Layouting +Lewandowski +Maximo +Modelling +NSE +ORCID +Paszty +Pathing +Pharma +Phuse +Postprocessing +Pre +Qi +RStudio +Resync +Rua +SKELETOMUSCULAR +STUDYID +Sabanés +Saibah +Stoilova +Subtable +Subtables +Tadeusz +Unstratified +ValueWrapper +Yung +afun +afuns +amongst +ard +args +biomarker +charset colcount combinatorial -CRAN's customizations -Davide de decrementing df @@ -30,77 +60,45 @@ elemtable emph facetted facetting -FFFL formatter forseeable funder -Garolini getter getters -Godwin -Heng -Hoffmann ie indicies ing initializer -Kelkhoff labelled -Layouting layouting -Lewandowski mandatorily -Maximo modelled -Modelling monospace -Mordig multivariable -NSE -ORCID orderable orthogonally oversimplifaction -Paszty pathability pathable pathed -Pathing pathing -Pharma -Phuse postfix postprocessing -Pre pre -Qi reindexed repped responder -Resync reusability roadmap -RStudio -rtables -Rua -Saban -Sabans -Saibah -SKELETOMUSCULAR sortable spl -Stoilova -STUDYID subseting subsplits -Subtable subtable subtable's -Subtables subtables summarization tableone -Tadeusz todo traversable truetype @@ -111,14 +109,8 @@ uniquification univariable unnested unpruned -Unstratified unstratified useR -ValueWrapper visibilities visibilty -Waddell xtable -Yogasekaram -Yung -Zhu From 0a3a9b9b14683e37d986384572977d8b4dc5a302 Mon Sep 17 00:00:00 2001 From: munoztd0 Date: Wed, 1 Jul 2026 12:19:55 +0000 Subject: [PATCH 4/5] fix: docs --- _pkgdown.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_pkgdown.yml b/_pkgdown.yml index 3191ece3d2..920ef45b63 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -180,6 +180,9 @@ reference: - make_split_result - spl_variable - make_subset_expr + - SplitValue + - splv_extra + - value_expr - title: Cell Formatting related Functions desc: cell formatting. From 9be3f55fd3a4057eb822ec40322b7304b3d8e5cb Mon Sep 17 00:00:00 2001 From: munoztd0 Date: Wed, 1 Jul 2026 12:20:48 +0000 Subject: [PATCH 5/5] fix: lintr --- tests/testthat/test-accessors.R | 80 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/testthat/test-accessors.R b/tests/testthat/test-accessors.R index 64d0be6670..9ca2107ba5 100644 --- a/tests/testthat/test-accessors.R +++ b/tests/testthat/test-accessors.R @@ -4,9 +4,9 @@ test_that("various accessors work at the layout/table level", { ## coltree col_extra_args <- rtables:::col_extra_args - l <- basic_table() %>% - split_cols_by("ARM") %>% - split_cols_by_multivar(c("AGE", "BMRKR1")) %>% + l <- basic_table() |> + split_cols_by("ARM") |> + split_cols_by_multivar(c("AGE", "BMRKR1")) |> analyze_colvars(list(mean, sd)) pred <- coltree(l, DM) @@ -227,31 +227,31 @@ test_that("header sep setting works", { # section_div tests ------------------------------------------------------------ test_structure_with_a_getter <- function(tbl, getter, val_per_lev) { # Main table obj - expect_identical(tbl %>% getter(), val_per_lev$global) + expect_identical(tbl |> getter(), val_per_lev$global) # Its labelrow (could be also not visible) - expect_identical(tt_labelrow(tbl) %>% getter(), val_per_lev$global_labelrow) + expect_identical(tt_labelrow(tbl) |> getter(), val_per_lev$global_labelrow) # First split row + its labels split1 <- tree_children(tbl)[[1]] - expect_identical(split1 %>% getter(), val_per_lev$split) - expect_identical(tt_labelrow(split1) %>% getter(), val_per_lev$split_labelrow) + expect_identical(split1 |> getter(), val_per_lev$split) + expect_identical(tt_labelrow(split1) |> getter(), val_per_lev$split_labelrow) # Content table checks if there content_elem_tbl <- content_table(split1) if (nrow(content_elem_tbl) > 0) { - expect_identical(content_elem_tbl %>% getter(), val_per_lev$content) - expect_identical(tt_labelrow(content_elem_tbl) %>% getter(), val_per_lev$content_labelrow) - expect_identical(tree_children(content_elem_tbl)[[1]] %>% getter(), val_per_lev$contentrow) + expect_identical(content_elem_tbl |> getter(), val_per_lev$content) + expect_identical(tt_labelrow(content_elem_tbl) |> getter(), val_per_lev$content_labelrow) + expect_identical(tree_children(content_elem_tbl)[[1]] |> getter(), val_per_lev$contentrow) } ## The elementary table has it? leaves_elementary_tbl <- tree_children(split1)[[1]] - expect_identical(leaves_elementary_tbl %>% getter(), val_per_lev$elem_tbl) - expect_identical(tt_labelrow(leaves_elementary_tbl) %>% getter(), val_per_lev$elem_tbl_labelrow) + expect_identical(leaves_elementary_tbl |> getter(), val_per_lev$elem_tbl) + expect_identical(tt_labelrow(leaves_elementary_tbl) |> getter(), val_per_lev$elem_tbl_labelrow) # Data rows has it? for (i in seq_len(nrow(leaves_elementary_tbl))) { - expect_identical(tree_children(leaves_elementary_tbl)[[i]] %>% getter(), val_per_lev$datarow[i]) + expect_identical(tree_children(leaves_elementary_tbl)[[i]] |> getter(), val_per_lev$datarow[i]) } } @@ -298,9 +298,9 @@ test_that("section_div getter and setter works", { ) fast_afun <- function(x) list("m" = rcell(mean(x), format = "xx."), "m/2" = max(x) / 2) - tbl <- basic_table() %>% - split_rows_by("cat", section_div = "~") %>% - analyze("value", afun = fast_afun, section_div = " ") %>% + tbl <- basic_table() |> + split_rows_by("cat", section_div = "~") |> + analyze("value", afun = fast_afun, section_div = " ") |> build_table(df) sdf <- section_div_info(tbl) @@ -330,10 +330,10 @@ test_that("section_div getter and setter works", { "Path appears invalid" ) - tbl_content <- basic_table() %>% - split_rows_by("cat", section_div = "~") %>% - summarize_row_groups() %>% # This makes them not visible - analyze("value", afun = fast_afun, section_div = " ") %>% + tbl_content <- basic_table() |> + split_rows_by("cat", section_div = "~") |> + summarize_row_groups() |> # This makes them not visible + analyze("value", afun = fast_afun, section_div = " ") |> build_table(df) sect_div_info_ok(tbl_content) @@ -531,10 +531,10 @@ test_that("section_div getter and setter works", { test_that("the split only setter works", { fast_afun <- function(x) list("m" = rcell(mean(x), format = "xx."), "m/2" = max(x) / 2) - tbla <- tbl <- basic_table() %>% - split_rows_by("ARM", section_div = "=") %>% - split_rows_by("STRATA1", section_div = "-") %>% - analyze("BMRKR1") %>% + tbla <- tbl <- basic_table() |> + split_rows_by("ARM", section_div = "=") |> + split_rows_by("STRATA1", section_div = "-") |> + analyze("BMRKR1") |> build_table(DM) sect_div_info_ok(tbl) replace_sec_div <- section_div(tbl) @@ -570,13 +570,13 @@ test_that("the split only setter works", { expect_identical(toString(tbl), toString(tbla)) # multiple analyze - tbl <- basic_table(header_section_div = " ") %>% - split_cols_by("ARM") %>% - split_rows_by("SEX", split_fun = drop_split_levels) %>% - analyze("AGE") %>% - split_rows_by("RACE", split_fun = drop_split_levels) %>% - split_rows_by("SEX", split_fun = drop_split_levels) %>% - analyze("AGE") %>% + tbl <- basic_table(header_section_div = " ") |> + split_cols_by("ARM") |> + split_rows_by("SEX", split_fun = drop_split_levels) |> + analyze("AGE") |> + split_rows_by("RACE", split_fun = drop_split_levels) |> + split_rows_by("SEX", split_fun = drop_split_levels) |> + analyze("AGE") |> build_table(DM) tbl2 <- tbl sect_div_info_ok(tbl) @@ -596,14 +596,14 @@ test_that("the split only setter works", { test_that("header_section_div works", { - lyt <- basic_table(header_section_div = "+") %>% - split_rows_by("STRATA1") %>% + lyt <- basic_table(header_section_div = "+") |> + split_rows_by("STRATA1") |> analyze("BMRKR1") expect_identical(header_section_div(lyt), "+") header_section_div(lyt) <- "<" expect_identical(header_section_div(lyt), "<") - tbl <- lyt %>% build_table(DM) + tbl <- lyt |> build_table(DM) expect_identical(header_section_div(tbl), "<") header_section_div(tbl) <- "+" expect_identical(header_section_div(tbl), "+") @@ -613,12 +613,12 @@ test_that("header_section_div works", { }) test_that("top_level_section_div works", { - lyt <- basic_table(top_level_section_div = "a") %>% - split_cols_by("ARM") %>% - split_rows_by("SEX", split_fun = drop_split_levels) %>% - analyze("AGE") %>% - split_rows_by("RACE", split_fun = drop_split_levels) %>% - split_rows_by("SEX", split_fun = drop_split_levels) %>% + lyt <- basic_table(top_level_section_div = "a") |> + split_cols_by("ARM") |> + split_rows_by("SEX", split_fun = drop_split_levels) |> + analyze("AGE") |> + split_rows_by("RACE", split_fun = drop_split_levels) |> + split_rows_by("SEX", split_fun = drop_split_levels) |> analyze("AGE") tbl <- build_table(lyt, DM) expect_identical(top_level_section_div(lyt), "a")