Let’s Look at Logical Variables & Operations in R Language:

Logical Operators can Basically have two Possible Values Either True or False

Logical Operators can be taken as TRUE/T or FALSE/F , it should be in capital Letters

Let us Look at few examples:

In R there are many Logical Operators, but here we will Look at the extremely used Operators

  1. == (Equal to)

Here 10 ==9, which is False , so false is returned in  console Pane.

2. < (less than)

Here result = 4 <5 , which is true, so result is Printed in Environment pane

3. ! (Not Operator)

Here result2 variable is assigned to Not true value ,so result2 returns Value false in Console & environment Panes.

4. Or Operator (|) :

Here result3 equals to result or result2

result Variable Holds TRUE and result2 Variable Holds False : T | F (TRUE or FALSE) = TRUE, hence the result3 Variable Holds TRUE

5. And Operator ( &):

Here result4 equals to result and result2

result Variable Holds TRUE and result2 Variable Holds False : T & F (TRUE AND FALSE) = FALSE, hence the result4 Variable Holds FALSE.

6. Checks whether result is True or False : isTRUE( ) :

Here res5 Variable checks the value of result variable is TRUE or not , result value is TRUE so res5 Value will be TRUE, similarly res6 Variable checks the Value of result2 Variable is TRUE or Not, result2 Variable is FALSE so res6 Value will be FALSE.

Itszzzzz Time to do some exercises to get Handy …… Keep Coding …

0 0 votes
Article Rating
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments