R/print.aovtable.R

##' @title Prints an anova table generated by aovtable()
##'
##' @details
##' No details yet...
##'
##' @param x An aov() model.
##' @param quote Print entries with surrounding quotes? Defualts to FALSE.
##' @param digits Number of significant digits.
##' @param print.mod Print model formula? Defaults to FALSE.
##' @return None. Used for its side effect.
##' @author David Braze \email{davebraze@@gmail.com}
##' @family aovtable
##' @seealso \code{\link[stats]{aov}}
##' @seealso \code{\link[base]{print}}
print.aovtable <-
    function(x,
             quote=FALSE,
             digits=3,
             print.mod=FALSE) {
  if (is.null(x$table) || is.null(x$model))
    stop("print.aovtable(): x does not have proper structure.\n")
  if (!"aovtable" %in% class(x))
    stop("print.aovtable(): x not of class 'aovtable'\n")
  tab <- x$table
  cat(sprintf("\nFormula: %s\n", attr(tab, "formula")))
  cat(sprintf("Units: %s\n", attr(tab, "units")))
  print.data.frame(tab, quote=quote, digits=digits)
  cat(sprintf("Multiple R2: %s\n", attr(tab, "R2")))
  if(print.mod) print(summary(x$model))
}
davebraze/FDB1 documentation built on May 14, 2019, 8:59 p.m.