[R] Combine two matricies

Michael Knudsen micknudsen at gmail.com
Mon Jul 13 11:46:56 CEST 2009


On Mon, Jul 13, 2009 at 11:31 AM, Tom Liptrot <tomliptrot at hotmail.com> wrote:

> 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:

This should do the trick:

x[which(is.na(x))]=a[which(is.na(x))]

--
Michael Knudsen
micknudsen at gmail.com
http://www.google.com/profiles/micknudsen




More information about the R-help mailing list