R/print.R

Defines functions print.anscombe

Documented in print.anscombe

# ============================== print.anscombe ===============================

#' Print method for objects of class "anscombe"
#'
#' `print` method for class "anscombe".
#'
#' @param x an object of class "anscombe", a result of a call to [`anscombise`]
#'   or [`mimic`].
#' @param ... Additional optional arguments to be passed to
#'   [`print`][print.default].
#' @details Just extracts the new dataset from `x` and prints it using
#'   [`print`][print.default].
#' @return The argument `x`, invisibly.
#' @seealso [`anscombise`] and [`mimic`]
#' @export
#' @md
print.anscombe <- function(x, ...) {
  if (!inherits(x, "anscombe")) {
    stop("use only with \"anscombe\" objects")
  }
  d <- length(attr(x, "new_stats")$means)
  xprint <- x[, 1:d]
  print(xprint, ...)
  return(invisible(x))
}

Try the anscombiser package in your browser

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

anscombiser documentation built on Oct. 3, 2022, 1:05 a.m.