title: Finding frequency of pairs within a dataset - R
body: <p>I have the following data:</p>
  
  <pre><code>Name    Event
  
  John    EventA
  Anna    EventA
  Dave    EventA
  Stew    EventB
  John    EventB
  Anna    EventB
  John    EventC
  Stew    EventC
  Dave    EventC
  </code></pre>
  
  <p>I want to find out who do the same events the most. So for example in the example above I want it to return that the top 3 most similar pairs are:
  John &amp; Anna, John &amp; Dave, John &amp; Stew.</p>
  
  <p>I assume I'd need to make a frequency matrix like the one below</p>
  
  <pre><code>Name    John    Anna    Dave     Stew
  John     0       2       2        2
  Anna     2       0       1        1
  Dave     2       1       0        1
  Stew     2       1       1        0
  </code></pre>
  
  <p>And then transform it to something like this:</p>
  
  <pre><code>Pair          Frequency
  
  John Anna         2
  John Dave         2
  John Stew         2
  Anna Dave         1
  Anna Stew         1
  Dave Stew         1
  </code></pre>
  
  <p>But I have no idea how to go about that.</p>
  
  <p>I'm working with R, so if anyone knows a way of doing this, it'd be a huge help!</p>