Duncan and Martin, Thank you for your replies.
I went with Martin's suggestion as it did not require loops and is probably the fastest...though it did take me 3 hours to figure out exactly how it was working !!! Here is what I am now using: bids = cbind(bids, timeCalc) orderBids = bids[order(bids$timeCalc),] # order bids on timeCalc col. result = orderBids[c(diff(orderBids$timeCalc) != 0,TRUE),] # get dataframe with last bid for each second Thanks again for advice. Chris -- View this message in context: http://r.789695.n4.nabble.com/Loop-too-slow-for-Bid-calc-BUT-cannot-figure-out-how-to-do-with-matrix-tp2955116p2966174.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.