Kevin, I'm sorry, but my code has a bug The correction is:
1) delete the two lines with 'ix' 2) replace them with for(i in 2:n) if(abs(x[i] - x[i-1]) < delta) x[i] <- x[i-1] + delta That's it. The problem is that it's back to slowness. Sorry, once again, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Lagged-values-problem-requiring-short-solution-time-tp4184566p4187126.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.