title: How can I get the complement of vector y in vector x
body: <p>That's <code>x \ y</code> using mathematical notation. Suppose</p>
  
  <pre><code>x &lt;- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2,1,1,1,3) 
  y &lt;- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1)
  </code></pre>
  
  <p>How can I get a vector with ALL the values in x that are not in y. i.e the result should be:</p>
  
  <pre><code>2,1,1,3
  </code></pre>
  
  <p>There is a similar question <a href="https://stackoverflow.com/questions/1837968/r-how-to-tell-what-is-in-one-vector-and-not-another">here</a>. However, none of the answers returns the result that I want.</p>