Re: [R] locating intervals (corrected version)

From: Dimitrios Rizopoulos <Dimitris.Rizopoulos_at_med.kuleuven.be>
Date: Wed 09 Aug 2006 - 04:39:31 EST

?findInterval() could be of help in this case.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
      http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting halldor bjornsson <halldor.bjornsson@gmail.com>:

> I have corrected a typo in my previous posting. In what follows the
> line with the inequality is correct
>
> Hi ,
>
> I have two sorted vectors X and Xi, where the range of Xi lies within the
> range of X.
>
> For an element in Xi, I want to find the neigbouring data in X, e.g. find an
> index ix
> so that for element number k, then
> X[ix[k]] < Xi[k] < X[ix[k] +1] # also OK with "<=" on either one, but not
> both
>
> This is easy to code by looping over the data in X,Xi, but I suspect there
> may be a faster and more elegant way to do this in R.
>
> In Python (Numeric) the same can be achieved with
> ix=Numeric.searchsorted(X[1:-1],Xi),
> which is quite compact.
>
> So, does anyone know of a corresponding R call that can achive the same?
>
> Sincerely,
> Halldˇr
>
>
> --
> Halldˇr Bj÷rnsson
> Deildarstj. Ranns. & Ůrˇun
> Ve­ursvi­ Ve­urstofu ═slands
>
> Halldˇr Bjornsson
> Weatherservice R & D
> Icelandic Met. Office
>
> [[alternative HTML version deleted]]
>
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



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 05:47:51 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 - 08:18:48 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.