Skip to content

vector question

2 messages · arun, William Dunlap

#
HI Andras,
Sorry, I misunderstood your question:

Try this:
?sapply(sapply(b,function(x) d[x<d]),`[`,1)
#[1] 12 36 36




----- Original Message -----
From: Andras Farkas <motyocska at yahoo.com>
To: arun <smartpink111 at yahoo.com>
Cc: 
Sent: Monday, June 17, 2013 2:48 PM
Subject: Re: [R] vector question

Arun,

thank you. Looking at it I am wondering if there is a way to get 36 in the result instead of the 24. The 2nd value in b is 24.6, therefore the 1st value greater then that in d is 36.

appreciate the help,

Andras
--- On Mon, 6/17/13, arun <smartpink111 at yahoo.com> wrote:

            
#
Or perhaps something based on findInterval, like
  > d[findInterval(b, c(d,Inf))+1]
  [1] 12 36 36
The details depend on if your inequality is strict or not.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com