I found that integer and double values ββbehave differently in the matrix and the wrong answer returned for only two data types.
#Test m <- matrix(1:12,4,3) which(!m[1,] %in% 1:5) which(!m[1,] %in% 1:5) [1] 3
However, when I changed the values ββin double / numeric,
m <- matrix(c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6), 4,3) which(!m[1,] %in% 0.10:0.35) [,1] [,2] [,3] [1,] 0.1 0.5 0.3 [2,] 0.2 0.6 0.4 [3,] 0.3 0.1 0.5 [4,] 0.4 0.2 0.6 which(!m[1,] %in% 0.10:0.35) [1] 2 3
there should be only 2 in the answer, because 1.3 are in the range from 0.10 to 0.35, why in the calculation they differ using integer and numerical. Thanks!