# 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[1] 14 >a – b[1] -2 >a * b[1]48 >b/a[1]1.33 >b%%a[1]1

Assignment Operators

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

Examples:

>a <- 2 >a[1]2 >a[1]4 >a[1]6

“<<- “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) >a[1]2 >m|n[1] TRUE TRUE TRUE TRUE ! m[1] TRUE FALSE FALSE FALSE > m||n[1] TRUE >a[1]2 >m&&n[1] FALSE >! m[1] TRUE FALSE FALSE FALSE >m &&n[1] 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 [1] TRUE > a > b[1] FALSE > a <= 5[1] TRUE > a <= 4[1] TRUE > a <= 5[1] FALSE > a == b[1] FALSE > a != b[1] TRUE