Aggregated data conditional on date

#1
Hi

I have some data, where I aggregate the information on a unique minute basis with the below code based on a dataset for 1 day.
I would however like to be able to run this code with a datafile that is combined of multiple days. I have a date column in the dataset, so I can use that as a unique identifier for each day.
Is there a way to aggregate the data on a 1 minute basis, given that the dates are unique?

The problem is that the
Code:
unique
function extracts the unique events that occur the first day, and then adds all the same events that happen in that minute afterwards. If i base it on the date too, I believe I can create unique 1-minute entries for each day in one long dataset.

Below is the code that works for a single days data.

Code:
novo <- read.csv("C:/Users/Morten/Desktop/data.csv", header = TRUE, stringsAsFactors=FALSE  )

TimeStamp <- novo[,1]
price <- novo[, 2]
volume <- novo[,3]
nV <- sum(volume) 

MinutesFloor <- unique(floor(TimeStamp))
nTradingMinutes <- length(MinutesFloor)

PriceMin <- rep(0, nTradingMinutes)
VolumeMin <- rep(0, nTradingMinutes)

for( j in 1:nTradingMinutes){
    ThisMinutes <- (floor(TimeStamp) == MinutesFloor[j])
    PriceMin[j] <- mean(price[ThisMinutes])
    VolumeMin[j] <- sum(volume[ThisMinutes])

    }
Thanks in advance

Data example:

date,"ord","shares","finalprice","time","stock"
20100301,C,80,389,540.004,1158
20100301,C,77,389,540.004,1158
20100301,C,60,389,540.004,1158
20100301,C,28,389,540.004,1158
20100301,C,7,389,540.004,1158
20100302,C,25,394.7,540.00293333,1158
20100302,C,170,394.7,540.00293333,1158
20100302,C,40,394.7,540.00293333,1158
20100302,C,75,394.7,540.00293333,1158
20100302,C,100,394.7,540.00293333,1158
20100302,C,1,394.7,540.00293333,1158
 
Last edited: