I'm assuming that you want to express r in terms of the other variables. Is this correct?

If you indeed want this (I'm changing the variables to those most commonly used to the equation I think it is.

Now you sum in BOTH sides of the equations:

EDIT: it was wrong before:

and finally,

So your calculations are, indeed, correct. Is this clear why it works?