View source: R/construct_diff.R
construct_diff | R Documentation |
This calls construct()
on two objects and compares the output using
diffobj::diffChr()
.
construct_diff(
target,
current,
...,
data = NULL,
pipe = NULL,
check = TRUE,
compare = compare_options(),
one_liner = FALSE,
template = getOption("constructive_opts_template"),
classes = NULL,
mode = c("sidebyside", "auto", "unified", "context"),
interactive = TRUE
)
target |
the reference object |
current |
the object being compared to |
... |
Constructive options built with the |
data |
Named list or environment of objects we want to detect and mention by name (as opposed to deparsing them further). Can also contain unnamed nested lists, environments, or package names, in the latter case package exports and datasets will be considered. In case of conflict, the last provided name is considered. |
pipe |
Which pipe to use, either |
check |
Boolean. Whether to check if the created code reproduces the object
using |
compare |
Parameters passed to |
one_liner |
Boolean. Whether to collapse the output to a single line of code. |
template |
A list of constructive options built with |
classes |
A character vector of classes for which to use idiomatic
constructors when available, we can provide a package instead of all its
classes, in the "{pkg}" form, and we can use a minus sign (inside the quotes)
to exclude rather than include. By default we use idiomatic constructors
whenever possible. The special values |
mode , interactive |
passed to |
Returns NULL
invisibly, called for side effects
## Not run:
# some object print the same though they're different
# `construct_diff()` shows how they differ :
df1 <- data.frame(a=1, b = "x")
df2 <- data.frame(a=1L, b = "x", stringsAsFactors = TRUE)
attr(df2, "some_attribute") <- "a value"
df1
df2
construct_diff(df1, df2)
# Those are made easy to compare
construct_diff(substr, substring)
construct_diff(month.abb, month.name)
# more examples borrowed from {waldo} package
construct_diff(c("a", "b", "c"), c("a", "B", "c"))
construct_diff(c("X", letters), c(letters, "X"))
construct_diff(list(factor("x")), list(1L))
construct_diff(df1, df2)
x <- list(a = list(b = list(c = list(structure(1, e = 1)))))
y <- list(a = list(b = list(c = list(structure(1, e = "a")))))
construct_diff(x, y)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.