sideBySide
Print Objects in Columns Next to Each Other

Description

Makes it easier to compare two or more objects by printing them in side-by-side columns.

Usage

sideBySide(x, PRINTFUN = NULL)
## S3 method for class 'sideBySide':
print(x, ..., PRINTFUN = attr(x, ".PRINTFUN"),
    sep = " | ", width = getOption("width"))

Arguments

x a list of one or more objects to be printed. If x is not a list, it is replaced by list(x), a list of length 1 containing the original x.
PRINTFUN the function (or name of the function) to use to print the elements of x. By default, "print".
sep a character string used as the separator between the side-by-side printouts of the elements of x.
width a positive integer giving the desired width of the printout, in characters.
... the arguments passed to PRINTFUN when the elements of x are printed.

Details

  1. options("width") is reduced by a factor of length(x).
  2. The elements of x are (virtually) printed with that width setting.
  3. The (virtually) printed lines are pasted together so the objects in x are printed side by side.
If the print methods for the objects do not keep within the requested reduced width, then the printed outputs will not be printed side by side. You might need to expand options("width"), and your window width, to get nice results.
Value
returns an object like x with the class "sideBySide" attached and an attribute, ".PRINTFUN", giving the default printing function to use.
Examples
sideBySide(list(NaiveFactorial=sapply(1:10,function(i)prod(1:i)),
                ViaGamma=gamma((1:10)+1)))
# may need options(width=124)
sideBySide(list(Default=terms(y ~ 1), NoIntercept=terms(y ~ -1)), PRINTFUN="str")
Package RinR version 6.0.0-69
Package Index