Description Usage Arguments Value Examples
objectdiff
is the central method used to generate "patches",
closures that record a minimal amount of information to convert one
object to another.
Objectdiff is an R package for measuring differences between arbitrary R objects using patches, a la Git. For example, if you have slightly modified a data.frame, and you would like to record the change, it would be more efficient to only record what is different, rather than a full copy of both data sets.
1 | objectdiff(old_object, new_object, ...)
|
old_object |
ANY. The "before" object. |
new_object |
ANY. The "new" object. These are usually a data.frame or an environment. |
... |
future compatibility for extensions to this generic. |
a function that can transform old_object
into new_object
,
but tries to keep memory footprint minimal. For example, if both are two
data.frame's of 100,000s of rows and 1,000s of columns, but the only change
made was the dropping of one column, the patching function will record
only that information and not a full copy of both datasets.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | iris2 <- iris[-1]
stopifnot(identical(objectdiff(iris, iris2)(iris), iris2))
beaver <- beaver1
patches <- list()
for (i in seq_len(10)) {
old_beaver <- beaver
beaver[seq(i*10, 9 + i*10), 1] <- i
patches <- c(patches, objectdiff(old_beaver, beaver))
}
stopifnot(identical(
beaver, Reduce(function(data, patch) patch(data), patches, beaver1)))
# The patches record the history of how we got from beaver1 to beaver
# We could go back to any previous step by applying only some of the
# patches.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.