[R] binary symmetric matrix combination

arun smartpink111 at yahoo.com
Thu Sep 19 15:36:57 CEST 2013


Hi Elio,
Try this:
library(stringr)
 lines1<-str_trim(gsub("\t"," ",readLines("elio.txt")))
 lst1<-lapply(split(lines1,cumsum(lines2=="")),function(x) x[x!=""])

lst2<- lapply(lst1[lapply(lst1,length)>0],function(x) as.matrix(read.table(text=x,row.names=1)))
names(lst2)<- paste0("m",seq_along(lst2))

lst2[1:2]
#$m1
 #    aa5 aa10 b253 b254
#aa5    0    1    1    1
#aa10   1    0    1    1
#b253   1    1    0    1
#b254   1    1    1    0
#
#$m2
 #   aa5 aa9 b27 b29
#aa5   0   1   1   1
#aa9   1   0   1   1
#b27   1   1   0   1
#b29   1   1   1   0


A.K.

________________________________
From: Elio Shijaku <selius at gmail.com>
To: arun <smartpink111 at yahoo.com> 
Sent: Thursday, September 19, 2013 3:27 AM
Subject: Re: binary symmetric matrix combination



Hi Arun,

Please find attached the text file. Let me know if anything else is needed. Thanks a lot for your continuous help.

Best,

Elio



More information about the R-help mailing list