I got tripped up with aggregating functions too.
My example is simpler, so it may be easier to understand what works or doesn't work and why by looking at it:
I believe the problem you are facing, is you need to have only ONE variable that is being aggregated in the WITH
statement. Then you can have one or more aggregation functions. Adding the r
broke things.
Here, I'm aggregating per Person and I can get the number of movies per person or average year.
MATCH (h:Person)-[r:ACTED_IN]->(m:Movie)
WITH h, count(m) as movies, avg(m.released) AS releaseYearAvg
RETURN h.name, movies, releaseYearAvg