Displaying 1 result from an estimated 1 matches for "common_d".
Did you mean:
common_2
2012 Mar 07
1
extract same columns and rows in two matrices
...###### 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 what I want
> rd
a b c
ra 15 12 9
rb 14 11 8
> ua
a b c
ra 1 3 5
rb 2 4 6
Thanks!
ben
[[alternative HTML version deleted]]