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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.