# R – Operators

R Operators are mainly categorised in to:

• Arithmetic Operators
• Assignment Operators
• Logical Operators
• Relational Operators

Arithmetic Operators

These operators are used for mathematical operations.

• Subtraction [-]
• Multiplication [*]
• Division [/]
• Exponential [^]
• Modulus [%%]
• Integer Division [%/%]

Examples:

 >a <- 6>b <- 8 >a +b 14 >a – b -2 >a * b48 >b/a1.33 >b%%a1

Assignment Operators

• Less than minus [< -]
• Equal to [=]
• Double less than minus [<<-]
• Minus greater than [- >]
• Minus double greater than [->>]

Examples:

>a <- 2 >a2 >a4 >a6

“<<- “and “->>” Operators are for assigning at a global level in the code.

Logical Operators

• Logical AND Operator [&&]
• Logical OR Operator [||]
• Logical NOT Operator [!]
• Element-wise Logical OR [|]
• Element-wise Logical AND [&]

Examples:

>a <- 2 > m <- c (FALSE, TRUE,2,7)> n – c(TRUE, FALSE,TRUE,FALSE) >a2 >m|n TRUE TRUE TRUE TRUE ! m TRUE FALSE FALSE FALSE > m||n TRUE >a2 >m&&n FALSE >! m TRUE FALSE FALSE FALSE >m &&n FALSE FALSE TRUE FALSE

Relational Operators

• Less than [<]
• Greater than [>]
• Less than equal to [<=]
• Greater than equal to [>=]
• Double Equal to [==]
• Not equal to [! =]

Examples:

 >a <-3 > b <- 7 > a < b  TRUE > a > b FALSE > a <= 5 TRUE > a <= 4 TRUE > a <= 5 FALSE > a == b FALSE > a != b TRUE