I've a data frame with time events on each row. In one row I've have the events types of sender (typeid=1) and on the other the events of the receiver (typeid=2). I want to calculate the delay between sender and receiver (time difference).

My data is organized in a data.frame, as the following snapshot shows:

If you reformulate the problem in more general terms, it would be easier to answer. I can make some sense of your code, but without more detailed information about the original data frame and what exactly you want to do, it is impossible to give you way of vectorizing the whole thing.
–
Joris MeysSep 10 '10 at 13:34