I am still pretty new to R, so would appreciate any help with the following task. I have a data frame or a matrix consisting of ~800 rows and two columns, the "AA", which stands for amino acid position in the protein, and the "Reported"column, which has the number of mutations hitting that particular position. The problem is that since there may be different mutations occurring at the same position, I may have multiple rows for the same position, each with different count. The starting data would like this (since there is no support for tables, please read the single row in pairs, 1 5, 100 18, 102 2, and so on):
AA Reported
1 5
100 18
102 2
102 13
103 4
103 3
103 2
103 3
I would like to loop through that table and create a new one that would contain only sums for each unique mutation position. The output should be this:
AA Reported
1 5
100 18
102 15
103 12
Would be glad for any help. It's a good opportunity to learn something new.