Re: [R] matrix merge problem

2009-04-14 Thread Luc Villandre
Hi Juan, Your first question can be answered easily. bin.matrix = matrix(A %in% B,nrow(A),ncol(A)) ; bin.vector = rowSums(bin.matrix) > 0 ; C = A[bin.vector,] ; This should do the trick. Cheers, Luc Juan Pablo Fededa wrote: Dear r-help contributors, I have two questions: first: I have a

Re: [R] matrix merge problem

2009-04-14 Thread Luc Villandre
Hi again, Your second problem can be solved with the "merge" function. Look at the help file with ?merge. Best of luck, Luc Juan Pablo Fededa wrote: Merci a lot!! On Tue, Apr 14, 2009 at 10:32 PM, Luc Villandre mailto:villa...@dms.umontreal.ca>> wrote: Hi Juan, Your first q

[R] matrix merge problem

2009-04-14 Thread Juan Pablo Fededa
Dear r-help contributors, I have two questions: first: I have a matrix A and a vector B. I want to make a new matrix C, which is made of the rows of A having a value included in B. Second: I have two matrixes A and B, of different dimensions. B has unique values in column 2 and A has not uniqu