Re: [R] locating intervals

From: Martin Maechler <>
Date: Wed 09 Aug 2006 - 19:25:09 EST

I'm pretty sure you want to use


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

Martin Maechler, ETH Zurich

>>>>> "halldor" == halldor bjornsson <>
>>>>> 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 mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.