compareFile {compare} | R Documentation |
Compare Several Objects
Description
Generate objects by running code from one or more files then compare the resulting objects to a set of model objects, allowing for and reporting on minor differences.
Usage
compareFile(filename, modelNames,
modelCode = NULL, modelSave = NULL, modelAnswers = NULL,
round = FALSE, ...)
compareFiles(filenames, modelNames,
modelCode=NULL, modelSave=NULL,
resultNames=filenames, ...)
Arguments
filename |
The name of a file containing R code. |
filenames |
A vector of names of files containing R code. |
modelNames |
A vector of names of objects of interest that should be generated by the code in the file(s). |
modelCode |
The name of a file that contains R code to generate model objects. |
modelSave |
The name of a binary file that can be used to load model objects. |
modelAnswers |
A list containing model objects. |
round |
A logical indicating whether to round, or an integer indicating how many digits to round to, or a function of one argument (that performs something like rounding), or a named list of any of those. |
resultNames |
A vector of names to be used to identify the results from different files. |
... |
For |
Details
The compareFile()
function is useful for comparing several
pairs of objects at once, where the comparison objects are generated
by running R code from a file and the model objects can be generated
in a number of ways.
The compareFiles()
function extends this to comparing the same
set of model objects to several different sets of comparison objects
(where each set of comparison objects is generated from a separate
file of R code).
For generating model objects, if a binary file is specified, that is
used in preference to source code; if a list of objects is provided,
that is used; and if no model objects are specified, they are
taken from the global workspace (using modelNames
).
The round argument may be a named list so that different rounding is applied to different comparisons.
Value
compareFile()
returns an object of class
"comparisonList"
, which is just a list of "comparison"
objects.
compareFiles()
returns an object of class
"comparisonListList"
. This is just a list of
"comparisonList"
objects, but a print method is defined to make
the display of this object a little more sane.
Author(s)
Paul Murrell
See Also
Examples
modelNames <- c("id", "age",
"edu", "class",
"IndianMothers")
compareFile(system.file("example", "student1.R", package="compare"),
modelNames,
system.file("example", "model.R", package="compare"))