title: Create a list from a complex comparison of two lists
body: <p>I am working on market transaction data where each observation contains the value of the variable of the buyer's id, and the value of the variable of the seller's id. For each observation (i.e each transaction), I would like to create a variable equal to the number of other transactions the associated seller has done <strong>with a different buyer</strong> than the one involved in this transaction. As a consequence, in the following</p>
  <pre><code>data &lt;- data.frame(Buyer_id = c(&quot;001&quot;,&quot;001&quot;,&quot;002&quot;,&quot;001&quot;), Seller_id = c(&quot;021&quot;,&quot;022&quot;,&quot;022&quot;,&quot;021&quot;))
  </code></pre>
  <p>I would like to obtain:</p>
  <pre><code>Result &lt;- list(0,1,1,0)
  </code></pre>
  <p>I searched for already existing answers for similar problems than mine, usually involving the function <code>mapply()</code>, and tried to implement them, but it proved unsuccessful.</p>
  <p>Thank you very much for helping me.</p>