Matrix logical operator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Matrix logical operator

Jérémie Juste

Hello,

I have some trouble understanding why !b &&TRUE is TRUE. Do you have an idea?


> b <- matrix(c(0,1,1,0,1,0),2)

> !b
      [,1]  [,2]  [,3]
[1,]  TRUE FALSE FALSE
[2,] FALSE  TRUE  TRUE
> !b &&TRUE
[1] TRUE


Best regards,

Jeremie

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Matrix logical operator

Berend Hasselman

> On 17 Jul 2017, at 07:27, Jeremie Juste <[hidden email]> wrote:
>
>
> Hello,
>
> I have some trouble understanding why !b &&TRUE is TRUE. Do you have an idea?
>
>
>> b <- matrix(c(0,1,1,0,1,0),2)
>
>> !b
>      [,1]  [,2]  [,3]
> [1,]  TRUE FALSE FALSE
> [2,] FALSE  TRUE  TRUE
>> !b &&TRUE
> [1] TRUE
>

Read the help for &&. You can see it like this: ?`&&`
Try

!b[1] && TRUE

and

!b[2] && TRUE


Berend hasselman

> Best regards,
>
> Jeremie
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Loading...