Skip to content
Prev 326307 / 398503 Next

change cell values

On Jul 3, 2013, at 2:27 PM, JiangZhengyu wrote:

            
I beleive the problem is that after the first NA assignment that mat1 will have changed. You need to record the status of both mat1 and mat2 before the change:
[,1]  [,2]  [,3] [,4]
[1,] FALSE FALSE  TRUE TRUE
[2,]  TRUE FALSE  TRUE TRUE
[3,] FALSE  TRUE FALSE TRUE
[,1]      [,2]     [,3] [,4]
[1,]  1.5599872  2.209537       NA   NA
[2,]         NA -1.144140       NA   NA
[3,] -0.8516326        NA 1.000368   NA
[,1]       [,2]     [,3] [,4]
[1,] 0.8863107 -0.3863741       NA   NA
[2,]        NA  1.3185811       NA   NA
[3,] 1.4487338         NA 1.051689   NA

There is also formalism:

is.na(object) <- logical.vector so it could have been:

is.na(mat1) <- both
is.na(mat2) <- both
David Winsemius
Alameda, CA, USA