title: Matching unordered values in R
body: <p>I'm working with a dataset with two columns that look something like this:</p>
  <pre><code>df &lt;- data.frame(
    Row1 = c(&quot;1, 2&quot;, &quot;2, 6, 4&quot;, &quot;3, 1&quot;, &quot;2, 1, 4&quot;, &quot;3&quot;),
    Row2 = c(&quot;2, 5&quot;, &quot;2, 6&quot;, &quot;1, 3&quot;, &quot;1, 4, 2&quot;, &quot;3, 2&quot;)
  )
  </code></pre>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Row1</th>
  <th>Row2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>&quot;1, 2&quot;</td>
  <td>&quot;2, 5&quot;</td>
  </tr>
  <tr>
  <td>&quot;2, 6, 4&quot;</td>
  <td>&quot;2, 6&quot;</td>
  </tr>
  <tr>
  <td>&quot;3, 1&quot;</td>
  <td>&quot;1, 3&quot;</td>
  </tr>
  <tr>
  <td>&quot;2, 1, 4&quot;</td>
  <td>&quot;1, 4, 2&quot;</td>
  </tr>
  <tr>
  <td>&quot;3</td>
  <td>&quot;3, 2&quot;</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to run a script that allows me to identify whether Row2 matches Row1. The need to have the same exact values, but they don't need to be in the same order. So given the above, I'd want a result that tells me the following:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Row1</th>
  <th>Row2</th>
  <th>Match</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>&quot;1, 2&quot;</td>
  <td>&quot;2, 5&quot;</td>
  <td>FALSE</td>
  </tr>
  <tr>
  <td>&quot;2, 6, 4&quot;</td>
  <td>&quot;2, 6&quot;</td>
  <td>FALSE</td>
  </tr>
  <tr>
  <td>&quot;3, 1&quot;</td>
  <td>&quot;1, 3&quot;</td>
  <td>TRUE</td>
  </tr>
  <tr>
  <td>&quot;2, 1, 4&quot;</td>
  <td>&quot;1, 4, 2&quot;</td>
  <td>TRUE</td>
  </tr>
  <tr>
  <td>&quot;3&quot;</td>
  <td>&quot;3, 2&quot;</td>
  <td>FALSE</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I've tried using match() and compare() and haven't found success with either. Match() produces TRUE as long as all the elements of Row1 are found in Row2, but this isn't what I'm looking for. I need to produce TRUE <em>only</em> when Row2 has the same exact numbers as Row1 and <em>only</em> those numbers, irrespective of order. On the other hand, Compare() produces an error if I try to create a new column to identify matches. This is what I enter:</p>
  <pre><code>df$match &lt;- compareIgnoreOrder(df$row1, df$row2)
  </code></pre>
  <p>I've also tried this way:</p>
  <pre><code>df$match &lt;- compare(df$row1, df$row2, ignoreAll = TRUE)
  </code></pre>
  <p>Both methods yield the following error: &quot;Input must be a vector, not a  object.&quot; And at this point I'm stuck. I've searched high and low but can't find any solutions. Help would be much appreciated.</p>