Skip to content
Prev 255911 / 398506 Next

Search arrays based on similar values

On Tue, Apr 05, 2011 at 05:34:50PM -0500, mjdubya wrote:
Hi.

The first column of B seems to contain consecutive integers 1:nrow(B).
If this is true, then try following

  B <- cbind(1:6, c(0.1, 0.3, 0.14, 0.2, 0.82, 0.21))
  A <- rbind(1, 1, 1, 2, 3, 3, 4, 6)
  cbind(B[A[, 1], 2])

Hope this helps.

Petr Savicky.