Re: [R] Combine multiple tables into one

2013-05-01 Thread arun
: Wednesday, May 1, 2013 10:47 PM Subject: Re: [R] Combine multiple tables into one Isn't this just a block diagonal matrix? library(pracma) blkdiag(table1, table2)     [,1] [,2] [,3] [,4] [1,]    1    1    0    0 [2,]    1    2    0    0 [3,]    0    0    0    1 [4,]    0    0    0    4 D

Re: [R] Combine multiple tables into one

2013-05-01 Thread Dennis Murphy
Isn't this just a block diagonal matrix? library(pracma) blkdiag(table1, table2) [,1] [,2] [,3] [,4] [1,]1100 [2,]1200 [3,]0001 [4,]0004 Dennis On Wed, May 1, 2013 at 5:41 PM, David Winsemius wrote: > add2blocks <- function(m

Re: [R] Combine multiple tables into one

2013-05-01 Thread David Winsemius
add2blocks <- function(m1, m2) { res <- cbind(m1, matrix(0, dim(m2)[1], dim(m2)[2]) ) res <- rbind(res, cbind( matrix(0, dim(m1)[1], dim(m1)[2]), m2) ) } new <- add2block(table1, table2) new #--- [,1] [,2] [,3] [,4] row11100 row212

Re: [R] Combine multiple tables into one

2013-05-01 Thread arun
Hi, May be this helps: dat1<- as.data.frame(table1)  dat2<- as.data.frame(table2) names(dat2)<-c("V3","V4") library(plyr) res<-join(dat1,dat2,type="full")  res[is.na(res)]<- 0  res #  V1 V2 V3 V4 #1  1  1  0  0 #2  1  2  0  0 #3  0  0  0  1 #4  0  0  0  4  combinedtable<-as.matrix(res)  colnames(