I have a data.frame and want to create a new column (varNEW) based on matching values in all rows of two existing columns (var1 and var2) using R. The new column should be the SUM of the matched column rows' values in a third column (var3). I have provided an example of the data.frame and the desired results below:
var1 var2 var3 varNew
a e 10 21
a e 11 21
b e 5 5
b f 1 1
c e 6 26
c e 20 26
d e 10 10
d f 9 9
Where do I start?