[R] Easy way?
ligges at statistik.uni-dortmund.de
Mon Jun 26 08:32:42 CEST 2000
> Yves Gauvreau wrote:
> Say I have this vector x <- sort(rnorm(n)). I'd like to know if there
> is a nice way to find out the index of the nearest x to say 1.5?
I would try:
which(abs(x - 1.5) == min(abs(x - 1.5)))
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help