title: Convert list of individuals to occurence of pairs in R
body: <p>I need specific format of data.frame for social structure analysis. How to convert data.frame containing list of individuals occuring together on multiple events:</p>
  
  <pre><code>my.df &lt;- data.frame(individual = c("A","B","C","B","C","D"),
                      time = rep(c("event_01","event_02"), each = 3))
  
    individual     time
  1          A event_01
  2          B event_01
  3          C event_01
  4          B event_02
  5          C event_02
  6          D event_02
  </code></pre>
  
  <p>into a data.frame containing occurence for each pairs (including [A,A]; [B,B] etc. pairs:</p>
  
  <pre><code>ind_1    ind_2   times
    A        A       0
    A        B       1
    A        C       1
    A        D       0
    B        A       1
    B        B       0
    B        C       2
    B        D       1
    C        A       1
    C        B       2
    C        C       0
    C        D       1
    D        A       0
    D        B       1
    D        C       1
    D        D       0
  </code></pre>