title: R calculate mode for three columns by ID
body: <p>My dataframe has a few single data (&quot;Weight&quot;, &quot;Temperature&quot;), and three scores for Hindlimb clasping (&quot;Hindlimb_1&quot;, &quot;Hindlimb_2&quot;, &quot;Hindlimb_3&quot;); all taken at different ages (&quot;Age&quot;).</p>
  <pre><code>str(hindlimb_data)
  'data.frame':   10 obs. of  12 variables:
   $ ID            : Factor w/ 25 levels &quot;26623&quot;,&quot;26625&quot;,..: 2 4 3 5 6 12 9 14 10 15
   $ Sex           : int  2 2 2 2 2 2 2 2 2 1
   $ Genotype      : Factor w/ 3 levels &quot;NTg&quot;,&quot;Transgenic_1&quot;,..: 3 2 3 2 2 3 2 3 2 3
   $ Group         : Factor w/ 2 levels &quot;Cross_sect&quot;,&quot;Longitudinal&quot;: 2 2 2 2 1 1 1 1 1 1
   $ Age           : num  8 8 8 8 8.5 7.5 7.5 7.5 7.5 7.5
   $ Weight        : num  30.8 31.2 28 27.5 32 33.2 26.7 32.5 27.2 29.2
   $ Temperature   : num  24.8 25.6 26.5 24.4 24.4 25.9 24.4 24.2 23.9 23.9
   $ Hindlimb_1    : num  2 2 3 0 2 2 0 2 2 0
   $ Hindlimb_2    : num  2 0 3 0 0 3 0 2 0 0
   $ Hindlimb_3    : num  2 0 3 0 0 2 0 2 0 1
   
  </code></pre>
  <p>I'm trying to calculate the mode of three Hindlimb clapsing data scores (&quot;Hindlimb_x&quot;) for each subject (&quot;ID&quot;). I only seem to be able to calculate this when each score is entered longwise, in a separate row (but this would duplicate values for the other variables in my dataframe; e.g. weight, temperature).</p>
  <p>Any ideas on how to code it?
  Thanks!</p>