[R] where two matrices differ?

Jonathan Daily biomathjdaily at gmail.com
Tue May 31 17:05:12 CEST 2011


Does this work for you?

which(is.nan(mat1 %% mat2), arr.ind = T)

On Tue, May 31, 2011 at 10:52 AM, Alaios <alaios at yahoo.com> wrote:
> Thanks alot.
> Unfortunately I can not apply this to much bigger matrices as I can not visually check all the components.
>
> Regards
> Alex
>
> --- On Tue, 5/31/11, Scott Chamberlain <scttchamberlain4 at gmail.com> wrote:
>
> From: Scott Chamberlain <scttchamberlain4 at gmail.com>
> Subject: Re: [R] where two matrices differ?
> To: "Alaios" <alaios at yahoo.com>
> Cc: R-help at r-project.org
> Date: Tuesday, May 31, 2011, 2:56 PM
>
>
>            The following returns zeros where elements do match, and NaN's where they don't match
>
> mat1 <- matrix(c(1,2,1,2), 2, 2)mat2 <- matrix(c(0,0,1,2), 2, 2)
> mat1 %% mat2
>
>
>
> ______________________Scott ChamberlainRice University, EEB Dept.
>
>
>                On Tuesday, May 31, 2011 at 8:41 AM, Alaios wrote:
>
>                    Dear all,
> I have a few matrices that are roughly the same (same dimensions).
> How I can find fast which are the elements that differ?
>
> Best Regards
> Alex
>
> ______________________________________________
> R-help at 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.
>
>
>
>
>
>
>
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
===============================================
Jon Daily
Technician
===============================================
#!/usr/bin/env outside
# It's great, trust me.



More information about the R-help mailing list