EVOLUTION-MANAGER
Edit File: sets.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: Set Operations</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 sets {base}"><tr><td>sets {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Set Operations</h2> <h3>Description</h3> <p>Performs <b>set</b> union, intersection, (asymmetric!) difference, equality and membership on two vectors. </p> <h3>Usage</h3> <pre> union(x, y) intersect(x, y) setdiff(x, y) setequal(x, y) is.element(el, set) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y, el, set</code></td> <td> <p>vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values.</p> </td></tr> </table> <h3>Details</h3> <p>Each of <code>union</code>, <code>intersect</code>, <code>setdiff</code> and <code>setequal</code> will discard any duplicated values in the arguments, and they apply <code><a href="vector.html">as.vector</a></code> to their arguments (and so in particular coerce factors to character vectors). </p> <p><code>is.element(x, y)</code> is identical to <code>x %in% y</code>. </p> <h3>Value</h3> <p>A vector of the same <code><a href="mode.html">mode</a></code> as <code>x</code> or <code>y</code> for <code>setdiff</code> and <code>intersect</code>, respectively, and of a common mode for <code>union</code>. </p> <p>A logical scalar for <code>setequal</code> and a logical of the same length as <code>x</code> for <code>is.element</code>. </p> <h3>See Also</h3> <p><code><a href="match.html">%in%</a></code> </p> <p>‘<a href="../../grDevices/html/plotmath.html">plotmath</a>’ for the use of <code>union</code> and <code>intersect</code> in plot annotation. </p> <h3>Examples</h3> <pre> (x <- c(sort(sample(1:20, 9)), NA)) (y <- c(sort(sample(3:23, 7)), NA)) union(x, y) intersect(x, y) setdiff(x, y) setdiff(y, x) setequal(x, y) ## True for all possible x & y : setequal( union(x, y), c(setdiff(x, y), intersect(x, y), setdiff(y, x))) is.element(x, y) # length 10 is.element(y, x) # length 8 </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>