Suppose I have a matrix like A=matrix(0,4,6) A[1,]=c(16,10,2,4,8,7) A[2,]=c(16,10,12,14,8,7) A[3,]=c(16,10,13,15,19,17) A[4,]=c(16,9,13,15,9,7)
> A [,1] [,2] [,3] [,4] [,5] [,6] [1,] 16 10 2 4 8 7 [2,] 16 10 12 14 8 7 [3,] 16 10 13 15 19 17 [4,] 16 9 13 15 9 7 I want to creat an indicator variable X which takes three values: X=1 if any of A[,2] to A[,4] is less than 10; for example, A[1,] and A[4,] is this group; X=2 if not the above but any of A[,5] to A[,6] is less than 10; for example, A[2,] is this group; X=3 if none of the above; for example, A[3,] belongs here. I wonder how to implement this fast in R? [[alternative HTML version deleted]] ______________________________________________ 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.