Problem with allocating data

#1
Hello,

Im currently writing my bachelor thesis in statistical finance and i have run into a small problem. I want to evaluate forcasts from my GARCH with realized intraday volatility. The intraday data is Tick-data over a certain period. The date column is presented as for example 2011-11-01 09:24:41 for different points in time. The other column is with the stock prices at that same time. What I want to do is to recieve the end courses of certain time intervals. For example i want to know what the closing course if for every five minute interval in the sample. In other words, i want to transform the tick-data into 5-minute-interval data. How do i write this code in R? Any help would be much appreciated and appropriately awarded.
 
#3
Okay, my approach has been like this:

The data has been converted to a time serie and look likes:

course
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:24:00 0.000000000
2011-11-01 08:24: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.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
2011-11-01 16:21:00 0.000000000
2011-11-01 16:30:00 0.004155960
2011-11-02 08:00:00 0.000000000
2011-11-02 11:50:00 0.000000000
2011-11-02 13:38:00 -0.002073009

and so on for 108 days (this stock is a small cap company, and therefore the infrequent trading)...

then i construct a sequence that consist all days there is no trade:

# Define m as the given days to loop through
start <- as.Date("2011-11-01")
end <- as.Date("2012-04-11")

# define a list of holidays
holidays <- as.Date(c("2011-12-26","2012-01-06","2012-04-06","2012-04-09",

## And days when there is no trading in the stock

"2012-01-03","2012-01-12","2012-01-16","2012-01-26","2012-03-23"))

# create a sequence of dates
allDates <- seq(start, end, by = "day")

# remove weekends
dayofweek <- as.POSIXlt(allDates)$wday
isweekend <- dayofweek==0L | dayofweek==6L
allDates <- allDates[!isweekend]

# delete holidays
allDates <- allDates[-match(holidays, allDates, nomatch = 0L)]

so then i control that both this sequence and my time serie consist of 108, and they do. Thereafter i am trying to perform this loop:

# Loop through all days
for(i in allDates){

# Take previoustick given intervall k
aggregatePrice(t, k=60,
marketopen="09:00:00", marketclose="17:30:00")
}

where the command aggregatePrice only work for one day at the time, and thats why im using the for() command, i want to perform this command for all days in the time serie.

But everytime i am getting this message:

Error in `[.xts`(t, i) : subscript out of bounds

I run traceback() and receive:

7: stop("subscript out of bounds")
6: `[.xts`(t, i)
5: t
4: is.data.frame(x)
3: colnames(a)
2: dataformatc(ts)
1: aggregatePrice(t, k = 60, marketopen = "09:00:00", marketclose = "17:30:00") at #4

I have been trying to understand why this happend and find a remedy, but so far i havent been able to solve the problem...

someone that might want to help me? please?!