EVOLUTION-MANAGER
Edit File: vec_unique.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 and count unique 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_unique {vctrs}"><tr><td>vec_unique {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Find and count unique values</h2> <h3>Description</h3> <ul> <li> <p><code>vec_unique()</code>: the unique values. Equivalent to <code><a href="../../base/html/unique.html">unique()</a></code>. </p> </li> <li> <p><code>vec_unique_loc()</code>: the locations of the unique values. </p> </li> <li> <p><code>vec_unique_count()</code>: the number of unique values. </p> </li></ul> <h3>Usage</h3> <pre> vec_unique(x) vec_unique_loc(x) vec_unique_count(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_unique()</code>: a vector the same type as <code>x</code> containing only unique values. </p> </li> <li> <p><code>vec_unique_loc()</code>: an integer vector, giving locations of unique values. </p> </li> <li> <p><code>vec_unique_count()</code>: an integer vector of length 1, giving the number of unique values. </p> </li></ul> <h3>Dependencies</h3> <ul> <li> <p><code><a href="vec_proxy_equal.html">vec_proxy_equal()</a></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>See Also</h3> <p><a href="vec_duplicate.html">vec_duplicate</a> for functions that work with the dual of unique values: duplicated values. </p> <h3>Examples</h3> <pre> x <- rpois(100, 8) vec_unique(x) vec_unique_loc(x) vec_unique_count(x) # `vec_unique()` returns values in the order that encounters them # use sort = "location" to match to the result of `vec_count()` head(vec_unique(x)) head(vec_count(x, sort = "location")) # Normally missing values are not considered to be equal NA == NA # But they are for the purposes of considering uniqueness vec_unique(c(NA, NA, NA, NA, 1, 2, 1)) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>