R/formatted.R

Defines functions `[.pak_preformatted` pak_preformat print.pak_preformatted format.pak_preformatted

#' @export

format.pak_preformatted <- function(x, ...) {
  attr(x, "pak_preformatted")
}

#' @export

print.pak_preformatted <- function(x, ...) {
  cat(format(x, ...), sep = "\n")
}

pak_preformat <- function(x, ...) {
  attr(x, "pak_preformatted") <- format(x, ...)
  class(x) <- c("pak_preformatted", class(x))
  x
}

#' @export

`[.pak_preformatted` <- function(x, i, j, drop = FALSE) {
  class(x) <- setdiff(class(x), "pak_preformatted")
  NextMethod("[")
}

Try the pak package in your browser

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

pak documentation built on June 8, 2025, 11:42 a.m.