Insignificant differences in the metadata (e.g., different dates and packet IDs) are excluded from the comparison.
Usage
orderly_compare_packets(
target,
current,
location = NULL,
allow_remote = NULL,
fetch_metadata = FALSE,
root = NULL
)
Arguments
- target
The id of the packet to use in the comparison.
- current
The id of the other packet against which to compare.
- location
Optional vector of locations to pull from. We might in future expand this to allow wildcards or exceptions.
- allow_remote
Logical, indicating if we should allow packets to be found that are not currently unpacked (i.e., are known only to a location that we have metadata from). If this is
TRUE
, then in conjunction withorderly_dependency()
you might pull a large quantity of data. The default isNULL
. This isTRUE
if remote locations are listed explicitly as a character vector in thelocation
argument, or if you have specifiedfetch_metadata = TRUE
, otherwiseFALSE
.- fetch_metadata
Logical, indicating if we should pull metadata immediately before the search. If
location
is given, then we will pass this through toorderly_location_fetch_metadata()
to filter locations to update. If pulling many packets in sequence, you will want to update this option toFALSE
after the first pull, otherwise it will update the metadata between every packet, which will be needlessly slow.- root
The path to the root directory, or
NULL
(the default) to search for one from the current working directory. This function does not require that the directory is configured for orderly, and can be anyoutpack
root (seeorderly_init()
for details).
Value
An object of class orderly_comparison. The object can be printed to
get a summary description of the differences, or passed to
orderly_comparison_explain()
to display more details.
Examples
# Here are two packets that are equivalent, differing only in id
# and times:
path <- orderly_example()
#> ✔ Created orderly root at '/tmp/Rtmp5CJVz5/orderly_ex_1ea8530a4cd7'
id1 <- orderly_run("data", root = path)
#> ℹ Starting packet 'data' `20251009-084329-f2d7c92f` at 2025-10-09 08:43:29.954035
#> > orderly_description(
#> + display = "A demo data set")
#> > x <- jitter(1:30)
#> > y <- 0.4 * x + 5 + rnorm(length(x), sd = 2)
#> > d <- data.frame(x, y)
#> > orderly_artefact("data.rds", description = "A synthetic dataset")
#> > saveRDS(d, "data.rds")
#> ✔ Finished running data.R
#> ℹ Finished 20251009-084329-f2d7c92f at 2025-10-09 08:43:30.023412 (0.06937695 secs)
id2 <- orderly_run("data", root = path)
#> ℹ Starting packet 'data' `20251009-084330-0c3f556c` at 2025-10-09 08:43:30.052424
#> > orderly_description(
#> + display = "A demo data set")
#> > x <- jitter(1:30)
#> > y <- 0.4 * x + 5 + rnorm(length(x), sd = 2)
#> > d <- data.frame(x, y)
#> > orderly_artefact("data.rds", description = "A synthetic dataset")
#> > saveRDS(d, "data.rds")
#> ✔ Finished running data.R
#> ℹ Finished 20251009-084330-0c3f556c at 2025-10-09 08:43:30.170023 (0.1175988 secs)
orderly_compare_packets(id1, id2, root = path)
#> ℹ Comparing packets 20251009-084329-f2d7c92f and 20251009-084330-0c3f556c...
#> ℹ The following attributes are different across the two packets:
#> • files
#> ℹ Use `orderly_comparison_explain(...)` to examine the differences in more detail.
# A more interesting comparison:
id1 <- orderly_run("parameters", list(max_cyl = 6), root = path)
#> ℹ Starting packet 'parameters' `20251009-084330-3acd07ea` at 2025-10-09 08:43:30.235222
#> ℹ Parameters:
#> • max_cyl: 6
#> > # This declares that this orderly report accepts one parameter
#> > # 'max_cyl' with no default (i.e., it is required).
#> > pars <- orderly_parameters(max_cyl = NULL)
#> > orderly_artefact("data.rds", description = "Final data")
#> > # We can use the parameter by subsetting 'pars'; unlike regular R
#> > # lists you will get an error if you try and access a non-existent
#> > # element.
#> > data <- mtcars[mtcars$cyl <= pars$max_cyl, ]
#> > saveRDS(data, "data.rds")
#> ✔ Finished running parameters.R
#> ℹ Finished 20251009-084330-3acd07ea at 2025-10-09 08:43:30.2731 (0.03787827 secs)
id2 <- orderly_run("parameters", list(max_cyl = 4), root = path)
#> ℹ Starting packet 'parameters' `20251009-084330-4d1cb4ef` at 2025-10-09 08:43:30.306577
#> ℹ Parameters:
#> • max_cyl: 4
#> > # This declares that this orderly report accepts one parameter
#> > # 'max_cyl' with no default (i.e., it is required).
#> > pars <- orderly_parameters(max_cyl = NULL)
#> > orderly_artefact("data.rds", description = "Final data")
#> > # We can use the parameter by subsetting 'pars'; unlike regular R
#> > # lists you will get an error if you try and access a non-existent
#> > # element.
#> > data <- mtcars[mtcars$cyl <= pars$max_cyl, ]
#> > saveRDS(data, "data.rds")
#> ✔ Finished running parameters.R
#> ℹ Finished 20251009-084330-4d1cb4ef at 2025-10-09 08:43:30.341973 (0.03539586 secs)
cmp <- orderly_compare_packets(id1, id2, root = path)
cmp
#> ℹ Comparing packets 20251009-084330-3acd07ea and 20251009-084330-4d1cb4ef...
#> ℹ The following attributes are different across the two packets:
#> • parameters
#> • files
#> ℹ Use `orderly_comparison_explain(...)` to examine the differences in more detail.
# A verbose comparison will show differences in the constituent
# components of each packet:
orderly_comparison_explain(cmp, verbose = TRUE)
#> ℹ Comparing packets 20251009-084330-3acd07ea and 20251009-084330-4d1cb4ef...
#> ℹ Comparing attribute `parameters`
#> < 20251009-084330-3acd07ea$parameters
#> > 20251009-084330-4d1cb4ef$parameters
#> @@ 1,3 / 1,3 @@
#> $max_cyl
#> < [1] 6
#> > [1] 4
#>
#> ! The following files differ across packets, but could not be compared as their content is binary:
#> • data.rds