On Sep 9, 2015, at 12:39 PM, Lida Zeighami wrote:

> Hi there,
> 
> I want to find the intersection between two different data frame or
> matrices based on two columns.
> for example in matrix A I have 5 columns, the first two columns are Id1 and
> Id2 and I have the same columns in the other matrix B, (Id1, Id2 ,,,)
> how can I find the intersection between these two matrices based on columns
> Id1 and Id2 in R?
> 

It's not clear to me what you mean by the intersection of matrices, but if you 
want the intersection of a column vector,  A[ ,'Id1'] , with another column 
vector, B[ , 'Id1'], then this produces the intersection (as a vector):

intersect( A[ ,'Id1'] , B[ , 'Id1'])


I suspect, however that your native language is not R or "database" (and 
perhaps not English) so my alternate hypothesis is that you really intend to 
_merge_ these "matrices", which I suspect are really dataframes:

my_inner_join <- merge(A, B, by=c("Id1", "Id2") )


> Thanks
> 
>       [[alternative HTML version deleted]]
> 

This is a plain text mailing list.

-- 

David Winsemius
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to