I have a dataframe as follows:
ID Unique_Val Group_val
1 4 5
1 6 5
2 8 3
2 4 3
Note that the data is in a long format where the group_val is duplicated for each row with the same ID. I'd like to get output as follows:
ID Unique_Val Group_val
1 10 5
2 12 3
Where we sum over the Unique_val for each ID, but preserve the Group_val. I know I could do some nasty looping, but I imagine there is an ellegent dpylr solution I can't figure out. Seems like summarize + group_by, but can't figure it out.