I have 19 rows worth of data with columns A and B which looks like this:

**A B**

0 6.5

1 6.4

2 6.3

3 6.1

4 6.0

... ...

If, for example, I wanted to combine rows A=0,1 and rows A=2,3,4, with column B taking the mean of the joint rows, how would I code this? I've tried using aggregate(), but am not sure how to combine the specific rows when they don't share a common value.

In the end, I want something like:

**A B**

0-1 6.45

2-4 6.13

... ...

Thanks in advance!