[R] Working with duplicated rows

Steve Murray
2009-01-12T15:52:26Z

Dear all,



I have a dataframe of 3 columns, consisting of 'longitude',
'latitude'
and a corresponding 'value'. Where identical 'longitude' and
'latitude'
pairs occur more than once, I want their corresponding 'value' to be
summed and the 'pair' to only appear once.



For example:



long   lat   value

10     20      5

6      2       3

27    -3       9

10     20      10

4     -1       0

6      2       9





would be converted to something like:



long   lat   value


10     20      15


6      2       12


27    -3       9


4     -1       0






...as rows 1 and 4, 2 and 6 respectively are matched with respect to
the 'long' and 'lat' columns. Their values in column 3 are then
summed
and reported as one row in the new dataframe.



How would I go about coding this in R?



Many thanks,



Steve


_________________________________________________________________
Are you a PC?? Upload your PC story and show the world