If you want to treat the NaNs as zero, make them zero:
r(isnan(r)) = 0;
Your calculation is then simply
R = [NaN; sum(W1(1:end-1, :) .* r(2:end, :), 2)] %no loop needed
I've put NaN for R(1) since you haven't specified in your description what it should be. Personally, I would simply change the offsets of R (i.e. have R(1) = sum(W1(1) .* r(2)))