Learn R Programming

rtables (version 0.4.0)

pag_tt_indices: Pagination of a TableTree

Description

Pagination of a TableTree

Usage

pag_tt_indices(
  tt,
  lpp = 15,
  min_siblings = 2,
  nosplitin = character(),
  colwidths = NULL,
  verbose = FALSE
)

paginate_table( tt, lpp = 15, min_siblings = 2, nosplitin = character(), colwidths = NULL, verbose = FALSE )

Arguments

tt

TableTree (or related class). A TableTree object representing a populated table.

lpp

numeric. Maximum lines per page including (re)printed header and context rows

min_siblings

numeric. Minimum sibling rows which must appear on either side of pagination row for a mid-subtable split to be valid. Defaults to 2.

nosplitin

character. List of names of sub-tables where page-breaks are not allowed, regardless of other considerations. Defaults to none.

colwidths

numeric vector. Column widths for use with vertical pagination. Currently ignored.

verbose

logical(1). Should extra debugging messages be shown. Defaults to FALSE.

Value

for pag_tt_indices a list of paginated-groups of row-indices of tt. For paginate_table, The subtables defined by subsetting by the indices defined by pag_tt_indices.

Examples

Run this code
# NOT RUN {
s_summary <- function(x) {
 if (is.numeric(x)) {
     in_rows(
         "n" = rcell(sum(!is.na(x)), format = "xx"),
         "Mean (sd)" = rcell(c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE)),
                             format = "xx.xx (xx.xx)"),
         "IQR" = rcell(IQR(x, na.rm = TRUE), format = "xx.xx"),
         "min - max" = rcell(range(x, na.rm = TRUE), format = "xx.xx - xx.xx")
     )
 } else if (is.factor(x)) {

     vs <- as.list(table(x))
     do.call(in_rows, lapply(vs, rcell, format = "xx"))

 } else (
     stop("type not supported")
 )
}


lyt <- basic_table() %>%
split_cols_by(var = "ARM") %>%
    analyze(c("AGE", "SEX", "BEP01FL", "BMRKR1", "BMRKR2", "COUNTRY"), afun = s_summary)

tbl <- build_table(lyt, ex_adsl)
tbl

nrow(tbl)

row_paths_summary(tbl)

tbls <- paginate_table(tbl)

w_tbls <- propose_column_widths(tbl) # so that we have the same column widths

tmp <- lapply(tbls, print, widths = w_tbls)

tmp <- lapply(tbls, function(tbli) {
  cat(toString(tbli, widths = w_tbls))
  cat("\n\n")
  cat("~~~~ PAGE BREAK ~~~~")
  cat("\n\n")
})


# }

Run the code above in your browser using DataLab