I have a table that is somewhat like this:

| var | RC |
| --- | --- |
| distance50 | 2 |
| distance20 | 4 |
| precMax | 5 |
| precMin | 1 |
| total\_prec | 8 |
| travelTime | 5 |
| travelTime | 2 |

I want to sum all similar type variables, resulting in something like this:

| var | sum |
| --- | --- |
| dist | 6 |
| prec | 14 |
| trav | 7 |

Using 4 letters is enough to separate the different types. I have tried and tried but not figured it out. Could anyone please assist? I generally try to work with dplyr, so that would be preferred. The datasets are small (n<100) so speed is not required.