Re: [R] Easy way?

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [R] Easy way?
Jan.Schelling@hydro.com
Date: Mon 26 Jun 2000 - 17:21:17 EST


Message-ID: <C125690A.0022E912.00@osla28smtp.hda.hydro.com>

try:

n <- 1000
x <- sort(rnorm(n))
x0 <- 1.5
dx <- abs(x-x0)
which(dx==min(dx))

Jan Schelling

From: cyg@sympatico.ca on 2000-06-25 23:47 GMT

To: r-help@stat.math.ethz.ch
cc: (bcc: Jan Schelling/HRE/Hydro)

Subject: [R] Easy way?

Hi,

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?

Thanks

YG


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:24 EST