Re: [R] locating intervals

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Wed 09 Aug 2006 - 19:25:09 EST

I'm pretty sure you want to use

findInterval()

Why did you not find it?
In other words, what did you try to find it?

Regards,
Martin Maechler, ETH Zurich

>>>>> "halldor" == halldor bjornsson <halldor.bjornsson@gmail.com>
>>>>> on Tue, 8 Aug 2006 16:47:18 +0000 writes:

    halldor> Hi , I have two sorted vectors X and Xi, where the     halldor> range of Xi lies within the range of X.

    halldor> For an element in Xi, I want to find the
    halldor> neigbouring data in X, e.g. find an index ix so
    halldor> that for element number k, then X[ix[k]] < X[k] <
    halldor> X[ix[k] +1] # also OK with "<=" on either one, but
    halldor> not both

    halldor> This is easy to code by looping over the data in
    halldor> X,Xi, but I suspect there may be a faster and more     halldor> elegant way to do this in R.
    halldor> In Python (Numeric) the same can be achieved with
    halldor> ix=Numeric.searchsorted(X[1:-1],Xi), which is quite
    halldor> compact.

    halldor> So, does anyone know of a corresponding R call that     halldor> can achive the same?

    halldor> Sincerely, Halldór

    halldor> -- Halldor Bjornsson Weatherservice R & D Icelandic     halldor> Met. Office



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. Received on Wed Aug 09 19:29:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 09 Aug 2006 - 20:22:53 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.