Hi, I would like to xor (bitwise) two matrices filled with binary values (0,1). The result of such XOR is expected to be 0,1. But apparently neither of xor nor bitXor is working in this case. I got ": binary operation on non-conformable arrays" error message when I used xor (M1,M2) . The problem with bitXor(M1,M2) is that it just truncates the result into a vector rather than a Matrix. Do you know if there is a way to solve this issue (without needing to implement custom XOR in this case). best, /Shahab
Hello, Your error message means that the arrays have different dim attributes. check with dim(M1) == dim(M2) They must be the same. If they are, the result is not 0/1 but FALSE/TRUE, which you can treat as or coerce to integer. Hope this helps, Rui Barradas Em 22-10-2012 16:44, shahab escreveu:> Hi, > > I would like to xor (bitwise) two matrices filled with binary values > (0,1). The result of such XOR is expected to be 0,1. > But apparently neither of xor nor bitXor is working in this case. > > I got ": binary operation on non-conformable arrays" error message > when I used xor (M1,M2) . > The problem with bitXor(M1,M2) is that it just truncates the result > into a vector rather than a Matrix. > > Do you know if there is a way to solve this issue (without needing to > implement custom XOR in this case). > > best, > /Shahab > > ______________________________________________ > 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.
You are right.Thanks a lot for the help Rui. best, /Shahab On Mon, Oct 22, 2012 at 5:52 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:> Hello, > > Your error message means that the arrays have different dim attributes. > check with > > dim(M1) == dim(M2) > > They must be the same. > If they are, the result is not 0/1 but FALSE/TRUE, which you can treat as or > coerce to integer. > > Hope this helps, > > Rui Barradas > Em 22-10-2012 16:44, shahab escreveu: >> >> Hi, >> >> I would like to xor (bitwise) two matrices filled with binary values >> (0,1). The result of such XOR is expected to be 0,1. >> But apparently neither of xor nor bitXor is working in this case. >> >> I got ": binary operation on non-conformable arrays" error message >> when I used xor (M1,M2) . >> The problem with bitXor(M1,M2) is that it just truncates the result >> into a vector rather than a Matrix. >> >> Do you know if there is a way to solve this issue (without needing to >> implement custom XOR in this case). >> >> best, >> /Shahab >> >> ______________________________________________ >> 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. > >
Maybe Matching Threads
- Error in "color2D.matplot" : "Error in plot.new() : figure margins too large"
- How to interpret Spearman Correlation
- [LLVMdev] bitwise AND selector node not commutative?
- [LLVMdev] bitwise AND selector node not commutative?
- [LLVMdev] bitwise AND selector node not commutative?