I have a dataframe:
data= data.frame( colA = c("house", "dog", "dog", "cat", "table", "table", "table"), colB= (c(1,2,6,3,9,1,7)))
and I would to create a new dataframe with unique elements of column colA and another column with the sums of numbers of colB that have the same element of colA.
Example:
data
colA colB
1 house 1
2 dog 2
3 dog 6
4 cat 3
5 table 9
6 table 1
7 table 7
new dataframe expected:
data1
colA colB
1 house 1
2 dog 8
3 cat 3
4 table 17