[R] aggregate

bogdan romocea br44114 at gmail.com
Wed May 11 22:14:37 CEST 2005


In fact since you have dates and not datetimes use as.Date() instead
of strptime().


On 5/11/05, bogdan romocea wrote:
> Assuming dfr["day","o","h","l","c"] and day like 2004-12-28:
> dt <- strptime(as.character(dfr$day),format="%Y-%m-%d") + 0
> wk <- format(dt,"%Yw%U")
> aggr <- aggregate(list(dfr$o,dfr$h,dfr$l,dfr$c),list(wk),mean)
> colnames(aggr) <- etc
> 
> -----Original Message-----
> From: Omar Lakkis [mailto:uofiowa at gmail.com]
> Sent: Wednesday, May 11, 2005 3:45 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] aggregate
> 
> I have a data frame of daily open, high, low and settle prices. How
> can I aggregate this data weekly?
> The data frame has five columns, the first is the date column and the
> rest are the prices.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list