R/print_helpers.R

Defines functions add_whitespace

#' @noRd

add_whitespace <- function(x,
                           mode = c("left", "right")) {
    mode <- match.arg(mode)
    x_max <- max(sapply(x, nchar))
    out <- sapply(x, function(xx) {
                      to_add <- paste0(rep(" ",
                                           x_max - nchar(xx)),
                                           collapse = "")
                      xx <- switch(mode,
                                   left = paste0(to_add, xx),
                                   right = paste0(xx, to_add))
                      xx
                    }, USE.NAMES = FALSE)
    out
  }

Try the manymome package in your browser

Any scripts or data that you put into this service are public.

manymome documentation built on Oct. 4, 2024, 5:10 p.m.