Re: [R] vector question

2013-06-17 Thread William Dunlap
to:r-help-boun...@r-project.org] On > Behalf > Of arun > Sent: Monday, June 17, 2013 11:58 AM > To: Andras Farkas > Cc: R help > Subject: Re: [R] vector question > > HI Andras, > Sorry, I misunderstood your question: > > Try this: >  sapply(sapply(b,function(x) d

Re: [R] vector question

2013-06-17 Thread arun
HI Andras, Sorry, I misunderstood your question: Try this:  sapply(sapply(b,function(x) d[x To: arun 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

Re: [R] vector question

2013-06-17 Thread arun
May be this helps: d[cumsum(sapply(d,function(x) any(x>b)))>=1] #[1] 12 24 36 A.K. - Original Message - From: Andras Farkas To: r-help@r-project.org Cc: Sent: Monday, June 17, 2013 2:29 PM Subject: [R] vector question Dear All, would you please help with the following: let us

[R] vector question

2013-06-17 Thread Andras Farkas
Dear All, would you please help with the following: let us say I have: a <-c(0,1,12,13,24,25,36,37) b <-c(6,24.6,27) #then I extract every 2nd element from "a" d <-a[seq(1, length(a), 2)] and what I need help with is to extract the 1st value from d that is greater than the values in b, so as a