Try this:

subset(merge(as.data.frame(A),
           cbind(as.data.frame(B), ID=1), all = T), is.na(ID), select = -ID)


On Mon, Jul 6, 2009 at 8:39 AM, dreamworx <andy_wools...@hotmail.com> wrote:

>
> I have 2 matrices. One which contains a complete set of row combinations.
> Another which contains a subset of the first. What I would like to extract
> is the rows which are in the first but not repeated in the second. For
> instance if the following were my two matrices,
>
> A
>       [,1] [,2] [,3] [,4]
>  [1,]    1    2    3    4
>  [2,]    1    2    3    5
>  [3,]    1    2    3    6
>  [4,]    1    2    3    7
>  [5,]    1    2    3    8
>  [6,]    1    2    3    9
>
>
> B
>       [,1] [,2] [,3] [,4]
>  [1,]    1    2    3    4
>  [2,]    1    2    3    5
>  [3,]    1    2    3    6
>  [4,]    1    2    3    9
>
>
> I would like to extract the following,
>
>       [,1] [,2] [,3] [,4]
>  [1,]    1    2    3    7
>  [2,]    1    2    3    8
>
> I would like to know if there is a simple solution to this problem? If I
> added the matrices and used the unique function, could I track which rows
> have been deleted? Otherwise, I can only think of performing a loop with an
> if statement.
> --
> View this message in context:
> http://www.nabble.com/Extracting-only-the-non-repeated-rows-of-matrices-tp24353933p24353933.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
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