Differences Between S-PLUS Objects

DESCRIPTION:

Show differences between two S-PLUS objects.

USAGE:

objdiff(x, y, file=tempfile("diff"), command="diff -c") 

REQUIRED ARGUMENTS:

x
a S-PLUS object.
y
a S-PLUS object.

OPTIONAL ARGUMENTS:

file
character string naming a file where the listing of differences should be written. If missing, a temporary file is created, and removed when the function exits.
command
character string naming a UNIX command to produce the listing of differences. This command is expected to take two file names as arguments and write its results on standard output.

VALUE:

if file is not missing, file, otherwise the exit status of command (multiplied by 256).

SIDE EFFECTS:

a difference listing is written on file.

DETAILS:

x and y are written to temporary files in the deparse format produced by dump. Then command is passed the names of these two files, and its output is sent to file. A pager is started on file with the S-PLUS function page.

NOTE:

This function is unrelated to diff, which computes numerical differences with time series data.

SEE ALSO:

, .

EXAMPLES:

myfun.old <- function(x) { apply(x, 2, mean) }
myfun.new <- function(x) { apply(x, 2, median) }
objdiff(myfun.old, myfun.new) 
# write the diff on "myfun.diff" and don't remove it:
objdiff(myfun.old, myfun.new, "myfun.diff") 
# write the diff on a new temp. file, and don't remove it:
objdiff(myfun.old, myfun.new, tempfile()) 
# compare an object with the same name on different databases:
stdev <- function(x) sqrt(var(x))
objdiff(get("stdev", where=2), get("stdev", where=1))
rm(stdev)