R/methods.R

Defines functions print.analyzerPlot plot.analyzerPlot

Documented in plot.analyzerPlot print.analyzerPlot

#' Plots a plot of class 'analyzerPlot'
#'
#' This function plots the plot generated by the library \code{analyzer}
#'
#' @param x a plot of class \code{analyzerPlot}
#' @param ... extra arguments if required
#'
#' @return Displays the plot
#'
#' @examples
#' # creating the plot
#' p <- plottr(mtcars)
#' plot(p$mpg)
#'
#' @export
plot.analyzerPlot <- function(x,
                              ...) {
  # removing the 'analyzerPlot' class from 'x' to prevent it from recurssion
  xclass <- class(x)
  xclass <- setdiff(xclass, "analyzerPlot")
  class(x) <- xclass
  # clearing the canvas and drawing the plot
  grid.newpage()
  grid.draw(x)
}


#' Method for print generic
#'
#' This function plots the plot generated by the library \code{analyzer}
#'
#' @param x a plot of class \code{analyzerPlot}
#' @param ... other parameters
#'
#' @return Displays the plot
#'
#' @examples
#' # creating the plot
#' p <- plottr(mtcars$mpg)
#' p$x
#'
#' @export
print.analyzerPlot <- function(x,
                               ...) {
  plot(x)
}

Try the analyzer package in your browser

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

analyzer documentation built on July 1, 2020, 10:02 p.m.