I have a data frame like this:
id no age 1 1 7 23 2 1 2 23 3 2 1 25 4 2 4 25 5 3 6 23 6 3 1 23
Assuming that your data frame is named df.
df
aggregate(no~id+age, df, sum) # id age no # 1 1 23 9 # 2 3 23 7 # 3 2 25 5