[R] compare and replace

Robert Ruser robert.ruser at gmail.com
Sat Nov 6 18:39:48 CET 2010


Thank you vary much Ben and Erik.
It's exactly what I want. Below is my a little modified example.

set.seed(12345)
X = sample(c(40:60),40,replace=TRUE)
x = matrix(X,nc=5)
y = c(40,43,55,60)
x[x %in% y] <- -1



More information about the R-help mailing list