search for: willdo

Displaying 1 result from an estimated 1 matches for "willdo".

2008 Jun 27
3
cumulative sum of within levels of a dataframe
...a 4 1 a 5 1 a 6 2 b 7 2 b 8 2 b 9 2 b 10 2 b 11 3 c 12 3 c 13 3 c 14 3 c 15 3 c I'd like to create another column in the dataframe so it looks like this, and make sure that the cumulative sums still match the right levels of the factor. I've included a "willdo" column that's just a cumulative sum, and an "ideal" column that's the cumulative sum minus the current value - the column headings are self explanatory. > answer x fac willdo ideal 1 1 a 1 0 2 1 a 2 1 3 1 a 3 2 4 1 a 4 3...