Dear smart ones, Image a vector 'test' that looks like so:
0 0.5 1.5 2.1 3.1 4 I'm looking for an efficient function that would do something like moddown <- function(test,integer){ for (element %in% test){ if (element%%integer != 0) { "return next lowest integer for which '%%' returns 0" } else { "return element" } } } and return for 'test' a vector like so: 0 0 0 2 2 4 My current solution like outlined above seems very inelegant ... Thanks for any hints, Joh ______________________________________________ R-help@stat.math.ethz.ch 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.