I have a data set where i need to obtain sum of various variables by grouping it by a variable in R. The data set is as follows:
V1 V2 V3 V4
1  2   3 a
5  6   7 a
3  2   3 b
5  6   7 b
I want the output in the form:
V1 V2 V3 V4
6  8  10  a
8  8  10  b
I want to use a loop for doing this. It will be great if someone can help
 
    