Hello everyone,Here is the version using dput. I am sorry for the junk I posted before. I have a large vehicle trajectory data of which following is a small part:  
structure(list(vehicle = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,2L, 2L), frame = c(221L, 222L, 223L, 224L, 115L, 116L, 117L, 118L, 119L, 120L, 121L), globalx = c(6451259.685, 6451261.244, 6451262.831, 6451264.362, 6451181.179, 6451183.532, 6451185.884, 6451188.237, 6451190.609, 6451192.912, 6451195.132), class = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), velocity = c(23.37, 23.16, 22.94, 22.85, 35, 35.01, 35.03, 34.92, 34.49, 33.66, 32.5), lane = c(5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L)), .Names = c("vehicle", "frame", "globalx", "class", "velocity", "lane"), row.names = c(85L, 86L, 87L, 88L, 447L, 448L, 449L, 450L, 451L, 452L, 453L), class = "data.frame")
Explanation of Columns:vehicle = unique ID of vehicle. It is repeated (in column) for every frame in which it was observed;frame= ID of the frame in which the vehicle was observed. One frame is 0.1 seconds long;class = class of vehicle i.e. 1=motorcycle, 2=car, 3=truck;velocity= velocity of vehicle in feet per second;lane= lane number in which vehicle is present in a particular frame;

'frame' number can also repeat e.g. in frame 120 the example data shows vehicle 2 was observed but in the original data many more vehicles might have been observed in this frame. Similarly, 'class' is defined above and all three classes are present in the original data (here example data only shows classes 2 and 3 i.e. cars and trucks).
I need to determine two things:1) Number of vehicles observed in every 30 seconds i.e. 300 frames 2) Average velocity of each vehicle class in every 30 seconds
> This means that the first step might be to determine the minimum and maximum frame numbers and then divide them in slots so that every slot has 300 frames. In my original data I found 22 as min and 9233 as max frame number. This makes 30 time slots as 22-322, 322-622, ..., 9022-9233. I need following columns in one table as an output (note that Timeslot column should contain the time intervals as described before): TimeSlot, Total-Cars, Total-Trucks, Total-Motorcycles, MeanVelocity-Cars, MeanVelocity-Trucks, MeanVelocity-Motorcycles


 		 	   		   		 	   		  
	[[alternative HTML version deleted]]


