Calculate cumulative sum based on other columns in R : I have a data frame like this:   

    wpt    ID   Fuel  Dist  Express   Local
     1     S36   12    1     1         0
     2     S36   14    4     1         0
     inter S36   15    7     0         1
     3     S36   18    10    0         1
     inter S36   20    12    1         0
     4     S36   23    17    1         0
     5     S36   30    20    1         0
     6     W09   45    9     0         1
     7     W09   48    14    0         1
     8     W09   50    15    0         1

I want to get **cumulative sum of Fuel and Dist** under each **Express and Local type**. The ideal output would be:   

    ID    sum.fuel    sum.dist   Express    Local
    S36     12          11          1         0
    S36     3           3           0         1
    W09     5           6           0         1

**Note:** There are **multiple blocks grouped by Express and Local**;  
To be clear, for **"S36"** under **Express** the cumulative fuel is defined by (14-12)+(23-20).  

Thanks in advance!!!
     

