I have a data frame with entries such as
GN Datum Land Wert
1 11747 2012-01-04 Thailand 7616
2 11747 2012-01-04 Thailand 6241
3 11747 2012-01-04 Thailand 1174
4 11747 2012-01-04 Thailand 2156
GN is the ID. But in this case, all four entries have the same ID. What I want is to summarize "Wert", so that in the end I have:
GN Datum Land Wert
1 11747 2012-01-04 Thailand 17187
How can I do this? I know I should probably use plyr
package or apply
or something, but I am pretty clueless where to start.
Secondly, let's say there are more variables in the data frame, and I don't want to group by them or summarize them, I just want to take their value - assuming they all have the same value in each group. How do I preserve those?