title: group nested data in R Studio
body: <p>In this data set, I have leaders and members. Each leader will have a certain number of corresponding members (from 2-8 members).</p>
  <p>I want to organise a dataframe that has a column of leader IDs, and then I want to have each row represent the average scores of that leader's members. Currently my data looks like this, where &quot;ID&quot; represents the member ID, and &quot;MATCH_ID&quot; represents the corresponding leader for that member.</p>
  <pre><code>   print(df)
        ID MATCH_ID total_number_groups
  1   1055     1036                  15
  2   1056     1036                  18
  3   1057     1036                  22
  4   1058     1042                  11
  5   1059     1042                  15
  6   1060     1042                  12
  10  1061     1036                  18
  11  1062     1036                  16
  12  1063     1042                  11
  13  1064     1042                  18
  14  1065     1036                  13
  </code></pre>
  <p>What I would like is to have MATCH_ID to only have one leader ID per row, and on the variable &quot;total_number_groups&quot;, I would like the average number of groups across members for that leader. (i.e. for leader 1036, the <em>average</em> score of their members total number groups = 17).</p>
  <p>Any ideas?</p>