Skip to content

Commit

Permalink
add indent size to matrix_form and toString methods for VTableTree
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbecker committed May 18, 2022
1 parent 8e92177 commit cdf6fac
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions R/tt_toString.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NULL
#' @param widths widths of row.name and columns columns
#' @param col_gap gap between columns
#' @param linesep character to create line separator
#' @param indent_size numeric(1). Number of spaces to use per indent level
#' @exportMethod toString
#'
#' @return a string representation of \code{x} as it appears when printed.
Expand All @@ -50,8 +51,10 @@ NULL
setMethod("toString", "VTableTree", function(x,
widths = NULL,
col_gap = 3,
linesep = header_sep(x)) {
toString(matrix_form(x, indent_rownames = TRUE),
linesep = header_sep(x),
indent_size = 2) {
toString(matrix_form(x, indent_rownames = TRUE,
indent_size = indent_size),
widths = widths, col_gap = col_gap,
linesep = linesep)
})
Expand Down Expand Up @@ -151,7 +154,8 @@ table_shell_str <- function(tt, widths = NULL, col_gap =3, linesep = "\u2014") {
#'
#' matrix_form(tbl)
setMethod("matrix_form", "VTableTree",
function(obj, indent_rownames = FALSE) {
function(obj, indent_rownames = FALSE,
indent_size = 2) {

stopifnot(is(obj, "VTableTree"))

Expand Down Expand Up @@ -212,8 +216,10 @@ setMethod("matrix_form", "VTableTree",

nr_header <- nrow(header_content$body)
if (indent_rownames) {
body[, 1] <- indent_string(body[, 1], c(rep(0, nr_header), sr$indent))
formats[,1] <- indent_string(formats[, 1], c(rep(0, nr_header), sr$indent))
body[, 1] <- indent_string(body[, 1], c(rep(0, nr_header), sr$indent),
incr = indent_size)
formats[,1] <- indent_string(formats[, 1], c(rep(0, nr_header), sr$indent),
incr = indent_size)
}

col_ref_strs <- matrix(vapply(header_content$footnotes, function(x) {
Expand Down

0 comments on commit cdf6fac

Please sign in to comment.