I am sorry for the previous mail, it happened due to the tables I copied into mail. Here is the text version:Hello everyone, I have a large vehicle trajectory data of which following is a small part: vehicle frame globalx class velocity lane 1 221 6451260 2 23.37 5 1 222 6451261 2 23.16 5 1 223 6451263 2 22.94 5 1 224 6451264 2 22.85 5 2 115 6451181 2 35.00 4 2 116 6451184 2 35.01 4 2 117 6451186 2 35.03 4 2 118 6451188 2 34.92 4 2 119 6451191 2 34.49 4 2 120 6451193 2 33.66 4 2 121 6451195 2 32.50 4 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 > output: TimeSlot Total-Cars Total-Trucks Total-Motorcycles MeanVelocity-Cars MeanVelocity-Trucks MeanVelocity-Motorcycles22-322322-622...9022-9233 Umair Durrani email: umairdurr...@outlook.com > Date: Fri, 24 Jan 2014 19:45:27 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] R 3.0.2 How to Split-Apply-Combine using various Columns > To: umairdurr...@outlook.com > > Hi, > > Please check your post and see how much helpful is for another person to copy > and paste your example dataset to run the code.Á It is always useful to use > ?dput() > dput(head(data,10)).Á Also, please post using plain text. [[alternative HTML version deleted]]
______________________________________________ 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.