0
我有以下數據,並且想知道Close在每年的最大值時的日期。在ddply中進行彙總時獲取which.max的行名
> str(ndvdf)
'data.frame': 1374 obs. of 2 variables:
$ Close: num 150 150 150 150 150 ...
$ Year : num 2009 2009 2009 2009 2009 ...
> head(ndvdf)
Close Year
2010-01-04 150.34 2009
2010-01-05 150.34 2009
2010-01-06 150.34 2009
我嘗試以下,但該行指數的回報,而不是日期和指標是每個年度的子集,因此很難用rownames得到的日期要麼。
> ddply(ndvdf, .(Year), summarise, MaxDate=which.max(Close))
Year MaxDate
1 2009 60
2 2010 244
3 2011 245
如何從我的數據中獲取日期? 謝謝。