How to change the label of a row based on the most frequent label? : <p>This is apparently a simple problem but I can't figure out what function to use. Following are sample data:  </p>

<pre><code>gg &lt;- data.frame(ID = c(15,15,15,16,16,16, 16,17,17,17),
                 ADO = c(rep("T1", 4), rep("T2", 2), rep("T3", 4)))
</code></pre>

<p>The "ID" is the label or category of a particular "ADO". It should be unique to each ADO. But in this case it is not:  </p>

<pre><code>&gt; table(gg$ID, gg$ADO)

     T1 T2 T3
  15  3  0  0
  16  1  2  1
  17  0  0  3  
</code></pre>

<p>I want to assign the most frequent ID to a particular ADO. So, my desired output is:  </p>

<pre><code>   ID ADO
1  15  T1
2  15  T1
3  15  T1
4  16  T2
5  16  T2
6  16  T2
7  16  T2
8  17  T3
9  17  T3
10 17  T3  
</code></pre>

<p>Please guide me what function can I use to fix this?</p>
