EVOLUTION-MANAGER
Edit File: vec_duplicate.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: Find duplicated values</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_duplicate {vctrs}"><tr><td>vec_duplicate {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Find duplicated values</h2> <h3>Description</h3> <ul> <li> <p><code>vec_duplicate_any()</code>: detects the presence of duplicated values, similar to <code><a href="../../base/html/duplicated.html">anyDuplicated()</a></code>. </p> </li> <li> <p><code>vec_duplicate_detect()</code>: returns a logical vector describing if each element of the vector is duplicated elsewhere. Unlike <code><a href="../../base/html/duplicated.html">duplicated()</a></code>, it reports all duplicated values, not just the second and subsequent repetitions. </p> </li> <li> <p><code>vec_duplicate_id()</code>: returns an integer vector giving the location of the first occurrence of the value. </p> </li></ul> <h3>Usage</h3> <pre> vec_duplicate_any(x) vec_duplicate_detect(x) vec_duplicate_id(x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vector (including a data frame).</p> </td></tr> </table> <h3>Value</h3> <ul> <li> <p><code>vec_duplicate_any()</code>: a logical vector of length 1. </p> </li> <li> <p><code>vec_duplicate_detect()</code>: a logical vector the same length as <code>x</code>. </p> </li> <li> <p><code>vec_duplicate_id()</code>: an integer vector the same length as <code>x</code>. </p> </li></ul> <h3>Missing values</h3> <p>In most cases, missing values are not considered to be equal, i.e. <code>NA == NA</code> is not <code>TRUE</code>. This behaviour would be unappealing here, so these functions consider all <code>NAs</code> to be equal. (Similarly, all <code>NaN</code> are also considered to be equal.) </p> <h3>Dependencies</h3> <ul> <li> <p><code><a href="vec_proxy_equal.html">vec_proxy_equal()</a></code> </p> </li></ul> <h3>See Also</h3> <p><code><a href="vec_unique.html">vec_unique()</a></code> for functions that work with the dual of duplicated values: unique values. </p> <h3>Examples</h3> <pre> vec_duplicate_any(1:10) vec_duplicate_any(c(1, 1:10)) x <- c(10, 10, 20, 30, 30, 40) vec_duplicate_detect(x) # Note that `duplicated()` doesn't consider the first instance to # be a duplicate duplicated(x) # Identify elements of a vector by the location of the first element that # they're equal to: vec_duplicate_id(x) # Location of the unique values: vec_unique_loc(x) # Equivalent to `duplicated()`: vec_duplicate_id(x) == seq_along(x) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>