[BioC] a question related to nested R loop

aiguo li li9212001 at yahoo.com
Mon Mar 22 17:43:53 CET 2010


Hi all,

I have a logical index matrix now and need to create a two column matrix that contains the row.names and col.names of this matrix where the logical index is TURE. 

The logical matrix is like this:

       Gene2   Gene1  Gene3
Gene1  TRUE    TRUE   FALSE

Gene2 FALSE   TRUE   FALSE

Gene3 FALSE   FALSE  TRUE

to create a list:

Gene1 Gene2
Gene1 Gene1
Gene2 Gene1
Gene3 Gene3

Here is my codes, which seems not working properly.
m=0;
for(i in 1:2909){
	for(j in 1:2909)
	{
	if(a[i,j]==TRUE) 
	GeneA[m]<-row.names(d)[i];
	GeneB[m]<-row.names(d)[j]
	m=m+1;
	}
	}

Thanks,

Anna



More information about the Bioconductor mailing list