EVOLUTION-MANAGER
Edit File: vec_proxy_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: Comparison and order proxy</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 vec_proxy_compare {vctrs}"><tr><td>vec_proxy_compare {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Comparison and order proxy</h2> <h3>Description</h3> <p><code>vec_proxy_compare()</code> and <code>vec_proxy_order()</code> return proxy objects, i.e. an atomic vector or data frame of atomic vectors. </p> <p>For <code><a href="new_vctr.html">vctrs_vctr</a></code> objects: </p> <ul> <li> <p><code>vec_proxy_compare()</code> determines the behavior of <code><</code>, <code>></code>, <code>>=</code> and <code><=</code> (via <code><a href="vec_compare.html">vec_compare()</a></code>); and <code><a href="../../base/html/Extremes.html">min()</a></code>, <code><a href="../../base/html/Extremes.html">max()</a></code>, <code><a href="../../stats/html/median.html">median()</a></code>, and <code><a href="../../stats/html/quantile.html">quantile()</a></code>. </p> </li> <li> <p><code>vec_proxy_order()</code> determines the behavior of <code>order()</code> and <code>sort()</code> (via <code>xtfrm()</code>). </p> </li></ul> <h3>Usage</h3> <pre> vec_proxy_compare(x, ...) vec_proxy_order(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vector x.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>These dots are for future extensions and must be empty.</p> </td></tr> </table> <h3>Details</h3> <p>The default method of <code>vec_proxy_compare()</code> assumes that all classes built on top of atomic vectors or records are comparable. Internally the default calls <code><a href="vec_proxy_equal.html">vec_proxy_equal()</a></code>. If your class is not comparable, you will need to provide a <code>vec_proxy_compare()</code> method that throws an error. </p> <p>The behavior of <code>vec_proxy_order()</code> is identical to <code>vec_proxy_compare()</code>, with the exception of lists. Lists are not comparable, as comparing elements of different types is undefined. However, to allow ordering of data frames containing list-columns, the ordering proxy of a list is generated as an integer vector that can be used to order list elements by first appearance. </p> <p>If a class implements a <code>vec_proxy_compare()</code> method, it usually doesn't need to provide a <code>vec_proxy_order()</code> method, because the latter is implemented by forwarding to <code>vec_proxy_compare()</code> by default. Classes inheriting from list are an exception: due to the default <code>vec_proxy_order()</code> implementation, <code>vec_proxy_compare()</code> and <code>vec_proxy_order()</code> should be provided for such classes (with identical implementations) to avoid mismatches between comparison and sorting. </p> <h3>Value</h3> <p>A 1d atomic vector or a data frame. </p> <h3>Dependencies</h3> <ul> <li> <p><code><a href="vec_proxy_equal.html">vec_proxy_equal()</a></code> called by default in <code>vec_proxy_compare()</code> </p> </li> <li> <p><code><a href="vec_proxy_compare.html">vec_proxy_compare()</a></code> called by default in <code>vec_proxy_order()</code> </p> </li></ul> <h3>Data frames</h3> <p>If the proxy for <code>x</code> is a data frame, the proxy function is automatically recursively applied on all columns as well. After applying the proxy recursively, if there are any data frame columns present in the proxy, then they are unpacked. Finally, if the resulting data frame only has a single column, then it is unwrapped and a vector is returned as the proxy. </p> <h3>Examples</h3> <pre> # Lists are not comparable x <- list(1:2, 1, 1:2, 3) try(vec_compare(x, x)) # But lists are orderable by first appearance to allow for # ordering data frames with list-cols df <- new_data_frame(list(x = x)) vec_sort(df) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>