[R] Fastest way of finding if any members of vector x fall in the range of the rows of matrix y

Petr PIKAL petr.pikal at precheza.cz
Fri Jun 24 13:37:59 CEST 2011


Hi


> Hi Dimitris,
> Thanks for your reply. But this is not exactly what i am after. I want 
to
> find the probes that falls into certain regions. In your solution it 
will
> ignore the second probe if it falls into the same region as the first 
one.
> Is there any vector trickb uilt in R to find whether probes fall into
> certain regions?
> best,
> salih

Can you explain what is probe and what is region and how Dimitri's code 
failed to do what you wanted?

Only if x is between y values you get one number in check negative and one 
positive and their multiplication is therefore lower than zero.

Regards
Petr


> 
> On Fri, Jun 24, 2011 at 10:23 AM, Dimitris Rizopoulos <
> d.rizopoulos at erasmusmc.nl> wrote:
> 
> > One approach is the following:
> >
> > x <- rnorm(5)
> > y <- matrix(rnorm(5*2), 5, 2)
> >
> > check <- y - x
> > check[, 1] * check[, 2] < 0
> >
> >
> > I hope it helps.
> >
> > Best,
> > Dimitris
> >
> >
> >
> > On 6/24/2011 10:57 AM, Salih Tuna wrote:
> >
> >>  Hi All,
> >> What is the fastest way of finding if any members of vector x fall in 
the
> >> range of the rows of matrix y?
> >> I do not want to use two for loops as this will take forever.
> >> Any help will be appreciated,
> >> best,
> >> salih
> >>
> >>        [[alternative HTML version deleted]]
> >>
> >> ______________________________**________________
> >> R-help at r-project.org mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/
> mailman/listinfo/r-help>
> >> PLEASE do read the posting guide http://www.R-project.org/**
> >> posting-guide.html <http://www.r-project.org/posting-guide.html>
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >>
> > --
> > Dimitris Rizopoulos
> > Assistant Professor
> > Department of Biostatistics
> > Erasmus University Medical Center
> >
> > Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
> > Tel: +31/(0)10/7043478
> > Fax: +31/(0)10/7043014
> > Web: http://www.erasmusmc.nl/**biostatistiek/<http://www.erasmusmc.nl/
> biostatistiek/>
> >
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list