I have a dataset as below:
Group Class
A 1
A 2
A 1
A 1
B 2
B 2
B 2
B 1
B 3
B 1
C 1
C 1
C 1
C 2
C 3
I want to aggregate the table by the ‘Group’ column and the value on the ‘Class’ column would be the Class with maximum count. For instance, for Group A, 1 appears three times, so the value for Class is 1. Similarly, for Group 2, 2 appears three times, so the value for Class is 2. The result table should be the following:
Group Class
A 1
B 2
C 1
I am new to R programming and would appreciate your help in solving this problem. Thanks!