Hi Petr, Thanks for your reply,
Actually it's not what I'm looking for. The aim is not simply to remove each value > 15. In my loop, I consider the first numeric value of my column as "correct". Then, I want to test the second value. If the absolute difference with the previous correct one is <15, it's a new correct one, but if it's >15, then it's a wrong one. If it's a wrong one, it has to test the third one to check if it's still >15 from the last correct value (first one). The value becomes correct again when the difference with the last correct one goes under 15 (and so, this value is the new "correct" one, and so one for the rest of the column). My loop is already doing the trick, but I just want to speed it up (or maybe another faster way to do the job). Hope it's more understandable right now! -- View this message in context: http://r.789695.n4.nabble.com/How-to-speed-up-a-double-loop-tp4704054p4704061.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.