> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Dennis Murphy
> Sent: Thursday, May 19, 2011 11:38 AM
> To: infoc...@gmx.net
> Cc: r-help@r-project.org
> Subject: Re: [R] vectorial search for elements wi
Hi:
Here's one possible approach:
A <- c(1,3,7,8,10)
B <- c(5,8)
apply(outer(A, B, '-'), 2, function(x) min(which(x >= 0)))
[1] 3 4
HTH,
Dennis
On Thu, May 19, 2011 at 2:58 AM, wrote:
> I have 2 vectors A and B. For each element of B I'd like to find the index of
> the next higher or equal e
I have 2 vectors A and B. For each element of B I'd like to find the index of
the next higher or equal element in A. And I'd like to store it effectiv. E.g.:
A <- c(1,3,7,8,10)
B <- c(5,8)
result: 3, 4
I have a possibility but for long vectors it works not very effectiv:
ans <- sapply(B, functi
3 matches
Mail list logo