Re: [R] merge matrix row data

2013-08-01 Thread arun
  D0407 D0409 D0410 D0462 D0463 D0473 D0475 D0488 D0489 D0492 #Conti_Australia 0 0 1 0 0 0 0 0 0 0 #Conti_Korea 0 0 0 0 0 0 0 0 0 0 #Conti_Malay 0 0 0 1 0 0     0     0     0     0  #   

Re: [R] merge matrix row data

2013-08-01 Thread arun
  0 1 0 0 0 0 #Conti_Malay 0 0 0 0 0 1 0 0 0 0 #Island_Sumatra  0 0 0 0 0     0     0     0     0 1 #    D0493 D0504 D0536 #Conti_Australia 0 0 1 #Conti_Malay 1 0 1 #Island_Sumatra 

Re: [R] merge matrix row data

2013-08-01 Thread arun
10 D0462 D0463 D0473 D0475 D0488 D0489 D0492 D0493 D0504 #IslandA 0 0 0 0 0 0 0 0 0 0 0 0 #IslandB     0     0 0 0 0 1 0 0 0 0 1 0  #   D0536 #IslandA 0 #IslandB 1 A.K. __

Re: [R] merge matrix row data

2013-08-01 Thread Elaine Kuo
t;> requested you to dput() the data to reduce these confusions. >> >> mat1<-as.matrix(read.table(text=" >> GID D0989 D9820 D5629 D4327 D2134 >> 1 100 1 0 >> 2 011 0 0 >> 4

Re: [R] merge matrix row data

2013-07-31 Thread arun
dA","IslandB"),function(x) {x1<- mat1[match(gsub(".*\\s+","",get(x)),mat1[,1]),-1];(!!colSums(x1))*1})) #    D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 A.K. ______

Re: [R] merge matrix row data

2013-07-31 Thread Elaine Kuo
10 0 0 > 7 010 0 1 > ",sep="",header=TRUE)) > IslandA<-c("GID 1", "GID 5") > IslandB<- c("GID 2", "GID 4", "GID > 7")t(sapply(c("IslandA","

Re: [R] merge matrix row data

2013-07-31 Thread Elaine Kuo
Sums(x1)})) > #D0989 D9820 D5629 D4327 D2134 > #IslandA FALSE FALSE TRUE FALSE TRUE > #IslandB TRUE FALSE FALSE TRUE FALSE > > t(sapply(c("IslandA","IslandB"),function(x) {x1<- > mat1[match(gsub(".*\\s+","",get(x)),row.names(m

Re: [R] merge matrix row data

2013-07-31 Thread arun
uot;IslandB"),function(x) {x1<- mat1[match(gsub(".*\\s+","",get(x)),row.names(mat1)),];!!colSums(x1)})) #    D0989 D9820 D5629 D4327 D2134 #IslandA  TRUE  TRUE FALSE  TRUE FALSE #IslandB FALSE  TRUE  TRUE FALSE  TRUE # "*1" will replace TRUE with 1 and FA

Re: [R] merge matrix row data

2013-07-31 Thread Bert Gunter
Time to do some homework, Elaine: ?regexp There are also numerous online tutorials on regular expressions that you can use to educate yourself. Cheers, Bert On Wed, Jul 31, 2013 at 2:07 PM, Elaine Kuo wrote: > Dear Arun > > Thank you for the very useful help. > However, please kindly explain t

Re: [R] merge matrix row data

2013-07-31 Thread Elaine Kuo
Dear Arun Thank you for the very useful help. However, please kindly explain the code below. row.names(mat1)<- gsub("[_]"," ",row.names(mat1)) 1. what does "[_]" mean? 2. what does " " mean? 3. what does row.names(mat1) mean? I checked ?gsub but still did not get the idea. Thank you again Ela

Re: [R] merge matrix row data

2013-07-31 Thread arun
HI, Please use ?dput() mat1<- as.matrix(read.table(text=" D0989  D9820  D5629  D4327  D2134 GID_1    1    0    0  1  0 GID_2    0    1    1  0  0 GID_4    0    0    1  0  0 GID_5    1    1    0  0  0 GID_7    0    1    0 

Re: [R] Merge matrix

2011-04-13 Thread Pankaj Barah
Hi Kevin, Sorry.it is not Bt ? A and B are two independent Matrices with equal number rows and different number of columns. dim (A) [1] 30380 104 dim(B) [1] 3038063 I want to combine both A and B to matrix C wheredim(C) [1] 30380 167 So I got the answer C<-cbind(A,B) Thanks and reg

Re: [R] Merge matrix

2011-04-12 Thread Kevin E. Thorpe
On 04/12/2011 10:54 AM, pankaj borah wrote: I have two matrices A and B dim (A) [1] 30380 104 dim(Bt) [1] 3038063 I want to combine both A and B to matrix C where dim(C) [1] 30380 167 How do I do that ? Assuming that Bt is the transpose of B and you want C = [A|Bt] you coul

Re: [R] Merge matrix

2011-04-12 Thread Kehl Dániel
?cbind should solve your problem 2011-04-12 07:54 keltezéssel, pankaj borah írta: > I have two matrices A and B > >> dim (A) > [1] 30380 104 > >> dim(Bt) > [1] 3038063 > > I want to combine both A and B to matrix C where >> dim(C) > [1] 30380 167 > > How do I do that ? > > > Regards, >