title: How to calculate overlap between different categories in R
body: <p>I have read around the forum but I have not found my desired answer. </p>
  
  <p>I have the following dataset:</p>
  
  <p><a href="https://i.stack.imgur.com/q0rIy.png" rel="nofollow noreferrer">Dataset</a></p>
  
  <p>The important columns are TGEClass and peptide:</p>
  
  <p>I would like to calculate the overlap between the different TGEclasses</p>
  
  <p>I used calculate.overlap(TGE) from VennDiagram but that does not give me the desired result;</p>
  
  <p>The R code with a dummy dataset:</p>
  
  <pre><code># A simple single-set diagram
  C1 &lt;- as.data.frame(letters[1:10])
  C2 &lt;- as.data.frame(letters[1:10])
  data =cbind(C1,C2)
  
  overlap &lt;- calculate.overlap(data)
  overlap = as.data.frame(overlap)
  </code></pre>
  
  <p>The R result:
  The result:</p>
  
  <pre><code>  a1 a2 a3
  1  a  a  a
  2  b  b  b
  3  c  c  c
  4  d  d  d
  5  e  e  e
  6  f  f  f
  </code></pre>
  
  <p>The desired result will look like this:</p>
  
  <p>TGEClass  </p>
  
  <p><a href="https://i.stack.imgur.com/RR843.png" rel="nofollow noreferrer">Desired Result</a></p>
  
  <p>10 genes are expressed in both TGE classes</p>
  
  <p>50 genes in only alternative</p>
  
  <p>60 genes in only short</p>
  
  <p>It is basically a ven diagram but in a table format. </p>
  
  <p>Please note that each gene have a different number of TGE class categories. </p>
  
  <p>I am very new to R so any help will be greatly appreciated.</p>
  
  <p>Thanks very much,</p>
  
  <p>Ishack </p>