I have a number of observations from the same unit, and I need to merge the rows. So a data frame like
data.frame(
fir =c("001","006","001", "006", "062"),
sec = c(10,5,6,7,8),
thd = c(45,67,84,54,23))
fir sec thd
001 10 45
006 5 67
001 6 84
006 7 54
062 8 23
The first column has a 3 digit number representing a unit. I need to add the rows together to get a total for each unit. The other columns are numeric values that need adding together. So the dataframe would look like,
fir sec thd
001 16 129
006 12 121
062 8 23
I need it to work for any unique number in the first column. Any ideas? Thank you for any help!