I have three different data frames like so:
V1.x<-c(1,2,3,4,5)
V2.x<-c(2,2,7,3,1)
V3.x<-c(2,4,3,2,9)
D1<-data.frame(ID=c("A","B","C","D","E"),V1.x=V1.x,V2.x=V2.x,V3.x=V3.x)
V1.y<-c(2,3,3,3,5)
V2.y<-c(1,2,3,3,5)
V3.y<-c(6,4,3,2,2)
D2<-data.frame(ID=c("A","B","C","D","E"),V1.y=V1.y,V2.y=V2.y,V3.y=V3.y)
V1<-c(3,2,4,4,5)
V2<-c(3,7,3,4,5)
V3<-c(5,4,3,6,3)
D3<-data.frame(ID=c("A","B","C","D","E"),V1=V1,V2=V2,V3=V3)
I would like to add up all of the V1 columns, all of the V2 columns, and all of the V3 columns
V1_Add<-D1$V1.x+D2$V1.y+D3$V1
V2_Add<-D1$V2.x+D2$V2.y+D3$V2
V3_Add<-D1$V3.x+D2$V3.y+D3$V3
Works just fine to get the individual column sums, but in the real data the column numbers go from V1:V80 so it would be great not to have to enter each collumn individually. Also, I would prefer to end up with one data frame that would contain all of the final sums like so:
ID V1 V2 V3
1 A 6 6 13
2 B 7 11 12
3 C 10 13 9
4 D 11 10 10
5 E 15 11 14