I have multiple variables to sum by group. The names of the variables have the exact same first character and ended from 1 to n. All variables to sum are side by side in data frame. All I could find is:
id<-1:nrow(df)
n<-length(id)
data2<-aggregate(cbind(vol_1,vol_2,vol_3,vol_4,vol_5,vol_6,vol_7,vol_8,vol_9,vol_10)~group,data=data1,sum,na.rm=T)
How can I be efficient knowing that n can change next time?