compare: Compare graphics output

Description Usage Arguments Details Value Note See Also Examples

Description

Compares plots/warnings/errors from plotExpr, plotFile, or plotFunction. For the text-based formats (i.e. pdf or ps), a .diff file is created. If ImageMagick is installed, plots of the differences will also be produced.

Usage

1
2
compare(test, control, path = test$info$directory, 
        erase = c("none", "identical", "files", "all"))

Arguments

test, control

either:

  • R objects of class qcPlotExpression, qcPlotFile, or qcPlotFunction.

  • Character vectors of the paths to the respective files, where relative paths are assumed unless an absolute path is given.

  • Character vectors of the directories which contain the log files to compare. The highest classed object in the folder will be chosen for comparison (i.e. if a plotFunction log is in the directory and many plotExpr logs, all of the plotExpr logs will be assumed to belong to the plotFunction log).

The specification for test and control can be mixed and matched, as long as the resulting objects are of the same class.

path

character vector; specifies where all the diff output (.diff files, plots of differences, and comparison logs) should be placed.

erase

character vector; one of "none", "identical", "files", or "all".

"none"

do not delete anything.

"identical"

delete plots in the test directory which were identical.

"files"

delete all plots (and .diff files) in the test directory (leaving only the log files).

"all"

delete all files created in the test directory and then the directory if it is empty

Currently only "none" is fully supported.

Details

Plots are compared using GNU diff. If a difference is detected and the current filetype being compared is a text-based format, a .diff file will be produced. If ImageMagick is installed, plots of differences will also be created.

It is possible for some plots to appear say, in the test group, but not in the control group (i.e. the function plot has an extra example plot in a new version of R). These such plots are classified as ‘unpaired’. Unpaired files do not have a corresponding plot to compare with so are separated into an unpaired section. It is also possible for entire filetypes to be unpaired. Currently if there is a completely unpaired function or file when trying to compare, recycling will be used. This is intended to change in the future.

In many instances, it is also useful to know whether there is any change in warnings or errors. If any difference is detected in the warnings/errors for a filetype, all of the warnings or errors (whichever had the difference detected) for that filetype are given. It is then up to the user to decide what the difference is (i.e. whether the ordering has changed or if one group has an extra warning etc.).

For each set of plot-logs being compared, a comparison log will be produced. So for each pair of qcPlotExprResult logs being compared, a comparison log will be produced with a name of the form ‘testPrefix+controlPrefix-compareExprLog.xml’. When comparing qcPlotFileResults or qcPlotFunctionResults there will also be a compareFileLog or compareFunLog produced which will take a name of the form ‘testPrefix+controlPrefix-compareFunLog.xml’, where the testPrefix and controlPrefix are chosen from the first prefixes in the set of compareExprLogs being compared (which in turn come from the first plotExpr logs). These logs are placed in path.

Value

A list of class qcCompareExprResult, qcCompareFileResult or qcCompareFunResult containing the results of the comparisons.

qcCompareExprResult files contain a list of info about the Operating System, R version, date, call, the info from the test, info from the control, and then information about the results of the comparisons (results by filetype giving the result, names of diff files and plots of differences if produced), including any unpaired plots or filetypes (with corresponding warnings/errors).

For qcCompareFile or qcCompareFun an initial info section is included, followed by a list containing each individual qcCompareExprResult.

Note

GNU diff must be installed on the system. ImageMagick is not necessary, but greatly extends functionality.

See Also

plotExpr, plotFile, plotFunction, writeReport

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
  # Create sets to compare (1st and 3rd are different)
  comp1 <- plotExpr(c("plot(1:10)", "plot(4:40)", "x<-3", "plot(2:23)"),
                    c("pdf", "ps"), "myPrefix", "comp1")
  comp2 <- plotExpr(c("plot(1:11)", "plot(4:40)", "x<-3", "plot(5:15)"),
                    c("pdf", "ps"), "myPrefix", "comp2")
  compExpr <- compare(comp1, comp2)
  # All the diff output has been placed in "comp1" (the test directory)
  compExpr
  # For a better way of viewing this, see ?writeReport

## End(Not run)

Example output

sh: 1: compare: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: compare: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Warning messages:
1: running command 'compare -version' had status 126 
2: running command 'compare -version' had status 126 
qcCompareExpr Result:
Call:
 compare(comp1, comp2) 
                        Test                        Control             Results 
R version: R version 3.4.4 (2018-03-15)  R version 3.4.4 (2018-03-15)           
Directory: /work/tmp/myPrefix            /work/tmp/myPrefix                     
Filename:  comp1-log.xml                 comp2-log.xml                          
Format:                                                                         
pdf        ...k/tmp/myPrefix/comp1-1.pdf ...k/tmp/myPrefix/comp2-1.pdf identical
           ...k/tmp/myPrefix/comp1-2.pdf ...k/tmp/myPrefix/comp2-2.pdf identical
           ...k/tmp/myPrefix/comp1-3.pdf ...k/tmp/myPrefix/comp2-3.pdf identical
ps         /work/tmp/myPrefix/comp1-1.ps /work/tmp/myPrefix/comp2-1.ps different
           /work/tmp/myPrefix/comp1-2.ps /work/tmp/myPrefix/comp2-2.ps different
           /work/tmp/myPrefix/comp1-3.ps /work/tmp/myPrefix/comp2-3.ps different

graphicsQC documentation built on May 2, 2019, 6:14 p.m.