EVOLUTION-MANAGER
Edit File: compare.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Provide human-readable comparison of two objects</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for compare {testthat}"><tr><td>compare {testthat}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Provide human-readable comparison of two objects</h2> <h3>Description</h3> <p><a href="https://lifecycle.r-lib.org/articles/stages.html#superseded"><img src="../help/figures/lifecycle-superseded.svg" alt='[Superseded]' /></a> </p> <p><code>compare</code> is similar to <code><a href="../../base/html/all.equal.html">base::all.equal()</a></code>, but somewhat buggy in its use of <code>tolerance</code>. Please use <a href="https://waldo.r-lib.org/">waldo</a> instead. </p> <h3>Usage</h3> <pre> compare(x, y, ...) ## Default S3 method: compare(x, y, ..., max_diffs = 9) ## S3 method for class 'character' compare( x, y, check.attributes = TRUE, ..., max_diffs = 5, max_lines = 5, width = cli::console_width() ) ## S3 method for class 'numeric' compare( x, y, tolerance = testthat_tolerance(), check.attributes = TRUE, ..., max_diffs = 9 ) testthat_tolerance() ## S3 method for class 'POSIXt' compare(x, y, tolerance = 0.001, ..., max_diffs = 9) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y</code></td> <td> <p>Objects to compare</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments used to control specifics of comparison</p> </td></tr> <tr valign="top"><td><code>max_diffs</code></td> <td> <p>Maximum number of differences to show</p> </td></tr> <tr valign="top"><td><code>check.attributes</code></td> <td> <p>If <code>TRUE</code>, also checks values of attributes.</p> </td></tr> <tr valign="top"><td><code>max_lines</code></td> <td> <p>Maximum number of lines to show from each difference</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>Width of output device</p> </td></tr> <tr valign="top"><td><code>tolerance</code></td> <td> <p>Numerical tolerance: any differences (in the sense of <code><a href="../../base/html/all.equal.html">base::all.equal()</a></code>) smaller than this value will be ignored. </p> <p>The default tolerance is <code>sqrt(.Machine$double.eps)</code>, unless long doubles are not available, in which case the test is skipped.</p> </td></tr> </table> <h3>Examples</h3> <pre> # Character ----------------------------------------------------------------- x <- c("abc", "def", "jih") compare(x, x) y <- paste0(x, "y") compare(x, y) compare(letters, paste0(letters, "-")) x <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis cursus tincidunt auctor. Vestibulum ac metus bibendum, facilisis nisi non, pulvinar dolor. Donec pretium iaculis nulla, ut interdum sapien ultricies a. " y <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis cursus tincidunt auctor. Vestibulum ac metus1 bibendum, facilisis nisi non, pulvinar dolor. Donec pretium iaculis nulla, ut interdum sapien ultricies a. " compare(x, y) compare(c(x, x), c(y, y)) # Numeric ------------------------------------------------------------------- x <- y <- runif(100) y[sample(100, 10)] <- 5 compare(x, y) x <- y <- 1:10 x[5] <- NA x[6] <- 6.5 compare(x, y) # Compare ignores minor numeric differences in the same way # as all.equal. compare(x, x + 1e-9) </pre> <hr /><div style="text-align: center;">[Package <em>testthat</em> version 3.1.5 <a href="00Index.html">Index</a>]</div> </body></html>