Hello, 'rank' function seems to be only for vectors, but i need to get the ranks for 3-dimensional arrays. See problems below. #Example Data a1<-array(1:12,c(2,3,2)); a2<-array(2,c(2,3,2)); a3<-array(0,c(2,3,2)) > a1 , , 1 [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 , , 2 [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12 > a2 , , 1 [,1] [,2] [,3] [1,] 2 2 2 [2,] 2 2 2 , , 2 [,1] [,2] [,3] [1,] 2 2 2 [2,] 2 2 2 > a3 , , 1 [,1] [,2] [,3] [1,] 0 0 0 [2,] 0 0 0 , , 2 [,1] [,2] [,3] [1,] 0 0 0 [2,] 0 0 0 rank(a1,a2,a3) #rank seems to be only for vectors Anybody knows how to rank these arrays and get the new arrays with ranks as their elements instead of original values? The results are like, > a1_rank , , 1 [,1] [,2] [,3] [1,] 2 3 3 [2,] 2.5 3 3 , , 2 [,1] [,2] [,3] [1,] 3 3 3 [2,] 3 3 3 > a2_rank , , 1 [,1] [,2] [,3] [1,] 2 2 2 [2,] 2.5 2 2 , , 2 [,1] [,2] [,3] [1,] 2 2 2 [2,] 2 2 2 > a3_rank , , 1 [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 , , 2 [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 Thanks a lot. -- ----------------- Jane Chang Queen's [[alternative HTML version deleted]]