Something that comes up often in my R fiddling, and that I haven't settled on a 'best practice' for, is 'get the next X [from vector A] after Y [from vector B]' Idea is to mesh trade 'entries' from A and 'exits' from B A reworked tidbit from one of Tom's programs, with apologies to him: exit <- unlist( sapply( entry, function(x) min( which( event> x)))) And I've independently found myself writing very similar lines [although 'anonymous functions' are against my religion, but that's a matter of style] But is there a better way? Anyone up for a Gedankenexperiment? Thanks, SW