Re: [R] need help to generate an intersection matrix

2017-02-02 Thread Jim Lemon
Hi Ana, Here is one way: pathway1<-LETTERS[1:5] pathway2<-c("A","C","F") pathway3<-c("B","D","E") intersect.mat<-matrix(0,nrow=3,ncol=3) rownames(intersect.mat)<-paste("pathway",1:3,sep="") colnames(intersect.mat)<-paste("pathway",1:3,sep="") for(row in 1:3) { for(col in 1:3) intersect.mat[row,

[R] need help to generate an intersection matrix

2017-02-02 Thread Li, Aiguo (NIH/NCI) [E]
Dear all, I am new to r script and run into some difficulty with this simple task. Here is my data: I need to find out the number of mutual intersected elements as shown below data pathway1 A B C D E pathway2 A C