Hi,
I wonder if someone can suggest how to create a new data.frame Y
from X where X$PL_Pos is summed by each unique X$MyDate. Y should end
up with two (or more) columns Y$MyDate and Y$PL_Sum with its value
being the cumsum of all the values in X for that date. - a 'daily
cumsum'.
Thanks,
Mark
Is this what you want:
aggregate(X$PL_Pos, list(X$MyDate), sum)
Group.1x
1 2009-08-03 174
2 2009-08-04 -26
3 2009-08-05 614
4 2009-08-06 318
5 2009-08-10 414
6 2009-08-11 -626
7 2009-08-12 544
8 2009-08-13 -106
9 2009-08-17 -146
10 2009-08-19 1004
11 2009-08-20 568
12
Jim,
It looks exactly like what I wanted. Thanks!
- Mark
On Fri, Aug 28, 2009 at 10:03 AM, jim holtmanjholt...@gmail.com wrote:
Is this what you want:
aggregate(X$PL_Pos, list(X$MyDate), sum)
Group.1 x
1 2009-08-03 174
2 2009-08-04 -26
3 2009-08-05 614
4 2009-08-06 318
Puting my 2cents:
newDF-data.frame(aggregate(X$PL_Pos, list(X$MyDate), sum))
colnames(newDF)-c(MyDate,PL_Pos_SUM)
good luck
milton
On Fri, Aug 28, 2009 at 1:03 PM, jim holtman jholt...@gmail.com wrote:
Is this what you want:
aggregate(X$PL_Pos, list(X$MyDate), sum)
Group.1x
1
The request for a date column results in a bit of redundancy beyond
what tapply would have produced, but here it is as specified:
data.frame(dnames=names(tapply(X$PL_Pos, X$MyDate, sum)), dsums =
tapply(X$PL_Pos, X$MyDate, sum) )
dnames dsums
2009-08-03 2009-08-03 174
5 matches
Mail list logo