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 <[EMAIL PROTECTED]>
>>>>>     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.

Reply via email to