title: How to convert a dyadic formatted dataset to an adjacency matrix?
body: <p>I have been trying hard to convert the following dyadic df to an adjacency matrix, working with several different approaches (reshape, dcast, ...) but didn't get what I wanted so far (It's a very long df, which is why I only add some exemplary lines here):</p>
  
  <pre><code>cntry1   cntry2    var1
  usa      canada      70
  usa      bahamas     29
  usa      cuba        39 
  canada   bahamas     15
  canada   cuba        35
  cuba     bahamas     5 
  </code></pre>
  
  <p>I'd like to have the above df in the following format:</p>
  
  <pre><code>            usa  canada bahamas  cuba     
  usa         0    70        29      39
  canada     70     0        15      35
  bahamas    29    15        0        5
  cuba       39    35        5        0
  </code></pre>
  
  <p>If I understood the various packages right (I am quite new to R), I would need to convert it from long to wide, which -however- is usually only done with edgelists of one id variable. </p>
  
  <p>Using it for my case, I receive the error message "Aggregation function missing: defaulting to length", which tells me that there seem to be non-unique values? - after reducing it to unique values the adjacency matrix is either complete for the rows or the columns but not both.  </p>
  
  <p>Is there any completely different approach you would recommend me to use?  </p>
  
  <p>Thanks a lot for your help!</p>