R: Difference R Output Files (original) (raw)

Rdiff {tools} R Documentation

Description

Given two R output files, compute differences ignoring headers, footers and some other differences.

Usage

Rdiff(from, to, useDiff = FALSE, forEx = FALSE,
      nullPointers = TRUE, Log = FALSE)

Arguments

from, to filepaths to be compared
useDiff should diff be used to compare results? Overridden to false if the command is not available.
forEx logical: extra pruning for ‘-Ex.Rout’ files to exclude headers and footers of examples, code and results for"--timings", etc.
nullPointers logical: should the displayed addresses of pointers be set to 0x00000000 before comparison?
Log logical: should the returned value include a log of differences found?

Details

The R startup banner and any timing information from R CMD BATCH are removed from both files, together with lines about loading packages. UTF-8 fancy quotes (see [sQuote](../../base/html/sQuote.html)) and on Windows, Windows' so-called ‘smart quotes’, are mapped to a simple quote. Addresses of environments, compiled bytecode and other exotic types expressed as hex addresses (e.g., ‘⁠<environment: 0x12345678>⁠’) are mapped to0x00000000. The files are then compared line-by-line. If there are the same number of lines and useDiff is false, a simple diff -b -like display of differences is printed (which ignores trailing spaces and differences in numbers of consecutive spaces), otherwise diff -bw is called on the edited files. (This tries to ignore all differences in whitespace: note that flag -w is not required by POSIX but is supported by GNU, Solaris and FreeBSD versions – macOS uses an old GNU version.)

There is limited support for comparing PDF files produced bypdf(compress = FALSE), mainly for use in make check– this requires a diff command and useDiff = TRUE.

Mainly for use in examples and tests, text from marker ‘⁠> ## IGNORE_RDIFF_BEGIN⁠’ up to (but not including) ‘⁠> ## IGNORE_RDIFF_END⁠’ is ignored. In examples, since R 4.4.0, the built-in Rd macro ⁠\dontdiff{}⁠can be used instead.

Value

If Log is true, a list with components status (see below) and out, a character vector of descriptions of differences, possibly of zero length.

Otherwise, a status indicator (invisibly), 0L if and only if no differences were found.

See Also

The shell script run as R CMD Rdiff, which usesuseDiff = TRUE.


[Package _tools_ version 4.6.0 Index]