[R] binary AND operators in R
djnordlund at verizon.net
Sun Mar 29 22:00:08 CEST 2009
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of mauede at alice.it
> Sent: Sunday, March 29, 2009 12:23 PM
> To: r-help at r-project.org
> Subject: [R] binary AND operators in R
> I cannot find any R function or operator that performs a
> binary AND operation, as performed by Fortran built-in
> function "iand".
> Ideally either R operator "&" or "&&" should do that. But
> some tests proved they do not:
> > A<- 1
> > B <- 2
> > A
>  1
> > B
>  2
> > as.numeric(A&B)
>  1
> > as.numeric(A&&B)
>  1
> The binary content of A should be "10000"
> The binary content of B should be "01000"
> Therefore the bitwise AND operator should yield 0 !
> I do not know how to fore the binary representation of an
> unsigned integer when writing R code.
> Do you know how to get around this problem ?
> Thank you so much.
I tried the search command
And found the package bitops on CRAN. Check and see if it has what you
Hope this is helpful,
Bothell, WA USA
More information about the R-help