title: R – How to calculate combinations of pairs?
body: <p>From a number of items (n), how do I compute all possible combinations of pairs in R? I can calculate the number of possible combinations with <code>(n-1)*(n-3)*(n-5)*…</code>, but how to get the combinations themselves?</p>
  
  <p>For example, I have</p>
  
  <pre><code>x &lt;- c("A", "B", "C", "D") 
  </code></pre>
  
  <p>That would make <code>4-1=3</code> combinations of pairs, so I want to have something like </p>
  
  <pre><code>("AB","CD")
  ("AC","BD")
  ("AD","BC")
  </code></pre>
  
  <p>Thanks a lot!</p>