Le mardi 08 mai 2012 à 10:44 +0200, osvald wiklander a écrit : > > > > Hi everybody, I am sorry that I am kind of spamming this forum, but I > have searched for some input everywhere and cant really find a nice > solution for my problem. > > Data looks like: > > price > 2011-11-01 08:00:00 0.000000000 > 2011-11-01 08:00:00 0.000000000 > 2011-11-01 08:02:00 0.000000000 > 2011-11-01 08:03:00 -0.017033339 > 2011-11-01 08:13:00 0.000690001 > 2011-11-01 08:24:00 0.000658411 > 2011-11-01 08:29:00 0.000000000 > 2011-11-01 08:29:00 0.000000000 > 2011-11-01 08:29:00 0.000000000 > 2011-11-01 08:29:00 0.000000000 > 2011-11-01 08:29:00 0.002166062 > 2011-11-01 08:44:00 0.000000000 > 2011-11-01 08:44:00 -0.002166062 > 2011-11-01 08:44:00 0.004321374 > 2011-11-01 10:36:00 0.010618976 > 2011-11-01 15:59:00 0.002092990 > > So the price column in fact shows the difference in the price of the > equity. It is about 100 days. > > I want to be able to convert this data to regurly spaced intervals, > like every fifth minute the previous tick is returned. > > So, for example I want that the new time serie should look like: > > price > 2011-11-01 08:00:00 0.000000000 > 2011-11-01 08:05:00 -0.017033339 > 2011-11-01 08:10:00 -0.017033339 > 2011-11-01 08:15:00 0.000690001 > 2011-11-01 08:20:00 0.000000000 > 2011-11-01 08:25:00 0.000658411 > 2011-11-01 08:30:00 0.002166062 > > And so on for the 100 days. And the I want to do this for ten minutes, > 30 minutes etc. > > Earlier I have tried with aggregatePrice() (in the RTAQ package) > combined with a for() loop. However this didnt work so well. > > I assume it exist some easy way to do this? However, as I said, I have > searched for a solution without any luck. > > So, what approach should I have? Have any of you done something like > this before? I think you should create a zoo object (from package zoo) from your data, and use aggregate() on it (see ?aggregate.zoo).
My two cents ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.