Michael Kao <mkao006rmail <at> gmail.com> writes:

> 
Well, taking a second look, I'd say it depends on the exact formulation.

In the applications I have in mind, I would like to count each occurrence
in B only once. Perhaps the OP never thought about duplicates in B

Hans Werner

> 
> Here is an example based on the duplicated function
> 
> test.mat1 <- matrix(1:20, nc = 5)
> 
> test.mat2 <- rbind(test.mat1[sample(1:5, 2), ], matrix(101:120, nc = 5))
> 
> compMat <- function(mat1, mat2){
>      nr1 <- nrow(mat1)
>      nr2 <- nrow(mat2)
>      mat2[duplicated(rbind(mat1, mat2))[(nr1 + 1):(nr1 + nr2)], ]
> }
> 
> compMat(test.mat1, test.mat2)
>

______________________________________________
R-help@r-project.org mailing list
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