[R-SIG-Finance] Handling half hourly data from electricity markets

jim green student.northwestern at gmail.com
Wed May 2 00:46:17 CEST 2012


Rui Barradas wrote
> 
> Hello,
> 
> 
> jim green wrote
>> 
>> Hi, 
>> 
>> I came across this message and found:
>> 
>> the years function doesn't work, actuall in zoo docomentation there is no
>> years function..
>> 
>> aggregate(cbind(X1, X2, X3) ~ peak + years(Date), DF, mean)
>> 
>> 
>> I tried 
>> aggregate(cbind(X1, X2, X3) ~ peak +
>> as.numeric(format(Date,format='%Y')), DF, mean)
>> aggregate(cbind(X1, X2, X3) ~ peak + as.POSIXlt(Date)$year+1900, DF,
>> mean)
>> 
>> but both don't work either..
>> 
>> Could someone pls advise?
>> 
>> Thanks!
>> Jim.
>> 
> 
> Function years exists, but in package chron.
> 
> With DF as above, Gabor's solution works.
> 
> library(chron)
> aggregate(cbind(X1, X2, X3) ~ peak + years(Date), DF, mean)
>    peak years(Date)     X1     X2     X3
> 1 FALSE        2011 19.845 16.450 19.565
> 2  TRUE        2011 16.490 15.000 15.090
> 3  TRUE        2012  7.025  7.175  6.130
> 
> Hope this helps,
> 
> Rui Barradas
> 

Thanks Rui, it works now!
Jim.


--
View this message in context: http://r.789695.n4.nabble.com/Handling-half-hourly-data-from-electricity-markets-tp3616106p4601924.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list