Hello R Community,
I have two data frame that i want to combine in one data frame in the following manner.
If the row's ID are the same, then add their values.
If the row's ID doesn't match, then append the rows without change their values.
I was wondering if there is any function in R that makes this operation or if it is necessary create a new function.
This is an illustration of what I looking for.
Many thanks in advance
#Before combining x & y x #> ID value #> 1 A 2 #> 2 B 3 #> 3 C 5 y #> ID value #> 1 A 1 #> 2 B 4 # After combining x and y get a result like this, where similar row's ID the value are added and # if the row's ID are different, then the row is appended to the end. res #> ID value #> 1 A 3 #> 2 B 7 #> 3 C 5
Created on 2021-07-24 by the reprex package (v2.0.0)