title: the max number of an occurence in R
body: <p>I have this array: </p>
  
  <pre><code> [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  1  1  1  1  1  1  1
    [25]  1  1  1  1  2  1  1  1  1  1  1  3  1  1  1  1  1  1  1  1  1  1  1  1
    [49]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
    [73]  1  1  1  1  1  4  3  2  5  3  2  3  3  2  3  2  3  2  3  3  2  3  3  2
    [97]  3  2  2  2  3  2  2  2  2  2  3  2  3  3  2  3  2  1  2  2  3  2  2  3
  </code></pre>
  
  <p>I need a function that returns only the number of the maximum occurrences. For example, if I use:</p>
  
  <pre><code>table(x[1:80])
  </code></pre>
  
  <p>I will get:</p>
  
  <pre><code> 1  2  3  4 
  74  3  2  1 
  </code></pre>
  
  <p>How can I get automatically the value '74'? Meaning that I can't know if '1' or '2' and so on... is the the maximum occurrence in my array. Thanks!</p>
  
  <p>Edit: </p>
  
  <p>I run:</p>
  
  <pre><code>tf&lt;- tablulate(x):
  
  [1] 75 24 19  1  1 
  </code></pre>
  
  <p>and tried to run a <code>for</code> loop to get the "maximum" of each element on the "tabulate result" as following:</p>
  
  <pre><code>for (element in tf)
  {
  + b= max(table(x[element]))
  + print (b)
  + }
  </code></pre>
  
  <p>I don't get the expected result, it is probably simple but not really for me.
  I tried this:</p>
  
  <pre><code>&gt; a=max(table(C[1:75]))
  [1] 72
  &gt; b=max(table(C[76:99]))
  [1] 11
  &gt; c=max(table(C[100:118]))
  [1] 12
  &gt; d=max(table(C[119]))
  [1] 1
  &gt; e=max(table(C[120]))
  [1] 1
  </code></pre>
  
  <p>and so on.
  and it works but it's really long and not fun if I have a big dataset.</p>