Displaying 1 result from an estimated 1 matches for "common_t".
Did you mean:
  common_2
  
2012 Mar 07
1
extract same columns and rows in two matrices
...names(rd1)= c('rc','rb','ra')
> rd1
c  b  a  d
rc 7 10 13 16
rb 8 11 14 17
ra 9 12 15 18
> ua
a b c
ra 1 3 5
rb 2 4 6
##################### get common columns and rows and order them the same,
this works but is slow'ish
rd1_cn = colnames(rd1)
ua_cn = colnames(ua)
common_t = merge(rd1_cn,ua_cn,by.x=1,by.y=1)
common_t = as.character(common_t[,1])
rd1 = rd1[,common_t]
ua = ua[,common_t]
rd1_d = rownames(rd1)
ua_d = rownames(ua)
common_d = merge(rd1_d,ua_d,by.x=1,by.y=1)
common_d = as.character(common_d[,1])
rd = rd1[common_d,]
ua = ua[common_d,]
############ this is...