R cumulative sum by factor, What I'm trying to get is the sum of the value when Type=A