
Hi,

I have two matricies a and x:

a<-matrix(c(3,4,5,2,3,4,1,1,2), nrow=3, ncol=3)

 [,1] [,2] [,3]
[1,]    3    2    1
[2,]    4    3    1
[3,]    5    4    2

x<-matrix(c(3, NA, NA, NA, 2, 5, NA, 2, 2), nrow=3, ncol=3)

 [,1] [,2] [,3]
[1,]    3   NA   NA
[2,]   NA    2    2
[3,]   NA    5    2

I wish to combine these two into one matrix using the values from x where x has values, and values from a where x has NA's, giving a new matrix which would look like this:

ax<-matrix(c(3,4,5,2,2,5,1,2,2), nrow=3, ncol=3)

    [,1] [,2] [,3]
[1,]    3    2    1
[2,]    4    2    2
[3,]    5    5    2

I want an automatic way of doing this as my actual application is a much larger matrix.

Thanks in advance

Tom


_________________________________________________________________

[[elided Hotmail spam]]


	[[alternative HTML version deleted]]


