Dear all, I found a difference between the indexing of an array and that of a matrix when there are NA's in the index array. The screen copy is as follows. > A <- array(NA, dim=6) > A [1] NA NA NA NA NA NA > idx <- c(1,NA,NA,4,5,6) > B <- c(10,20,30,40,50,60) > A[idx] <- B > A [1] 10 NA NA 40 50 60 > AA <- matrix(NA,6,1) > AA [,1] [1,] NA [2,] NA [3,] NA [4,] NA [5,] NA [6,] NA > AA[idx,1] <- B > AA [,1] [1,] 10 [2,] NA [3,] NA [4,] 20 [5,] 30 [6,] 40 > In the case of a array, we miss the elements (20 and 30) in B corresponding to the NA's in the index array. In the case of a matrix, 20 and 30 are assigned to the elements indexed by the indexes following the NA's. Is this a reasonable behavior. Thanks in advance for explanation. -MY
[[alternative HTML version deleted]] ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html