Re: [R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread David Winsemius
On Sep 15, 2010, at 7:40 PM, Dennis Murphy wrote: Hi: Try something like this: ind <- as.matrix(expand.grid(rownames(U), colnames(U))) Uempty[ind] <- U[ind] ind should be a two column matrix of (row, col) indices. Then just replace the values of Uempty associated with those indices with th

Re: [R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Dennis Murphy
Hi: Try something like this: ind <- as.matrix(expand.grid(rownames(U), colnames(U))) Uempty[ind] <- U[ind] ind should be a two column matrix of (row, col) indices. Then just replace the values of Uempty associated with those indices with the corresponding entries of U. HTH, Dennis On Wed, Sep

Re: [R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Jorge Ivan Velez
Hi Nicolas, Try (untested): with(pop, table(factor(xloc, levels = 1:20), factor(loc, levels = 1:25))) HTH, Jorge On Wed, Sep 15, 2010 at 7:31 PM, Nicolas Gutierrez <> wrote: > Hi All, > > I’m trying to superimpose (or "add") two matrices: > > 1. resulting from a table function with frequenci

[R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Nicolas Gutierrez
Hi All, I’m trying to superimpose (or "add") two matrices: 1. resulting from a table function with frequencies: > U=table(pop$xloc, pop$yloc)) 14 15 16 17 18 19 20 21 22 5 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0