Flat 20% & up to 50% off + Free additional Courses. Hurry up!


An operator is a symbol that notifies compiler to do certain mathematical or logical manipulations. R’s binary and logical operators will look common for programmers. And also binary operators work on vectors and matrices and also scalars.

There are different types of operators; They are:

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

Arithmetic Operators

These are the operators which do simple calculation depending on operators used.

The operators used here are:

Addition (+), Subtraction (-), Multiplies both vectors (*), division (/), modulus (%%), integer division to get quotient (%/%) and Exponential operators (^)

For example:

p<- c(3, 2.5, 8)

q<- c(6, 2, 3)



[1] 0 1 2

Logical Operators

It is applicable to vectors of logical type, numeric or complex. All numbers greater than 1 are considered logically as TRUE. The result of each element of the first vector is compared with the corresponding element of the second vector is Boolean Value.

Logical Operators “&” and “|”  Element-wise logical Operators. ! is a Logical NOT operator.

Also && and || are called Logical AND operator and Logical OR operator respectively. But the logical operation considers the only first element of both the vectors and gives TRUE or FALSE.

Example: &&

s <- c(2,0,FALSE,4+1i)

p<- c(1,0,TRUE,2+0i)



[1] TRUE


Relational Operators

Relational Operators check the corresponding element of vector. The result of comparison is Boolean.

Operators: >, <, ==, <=, >=, !=

Example for >= operator:

a <- c(3, 4, 5, 6)

b <- c(2,6, 8, 0)




Assignment Operators

The Assignment operators are used to assign the values to the vectors.

There are 2 types of assignment operators, they are Left Assignment(<- or = or <<-) and Right Assignment(-> or ->>)


s1 <- c(2,1,TRUE, 2+3i)

s2 <- c(2,1,TRUE, 2+3i)

s3 = c(2,1,TRUE, 2+3i)





[1]  2+0i 1+0i 1+0i 2+3i

[2]  2+0i 1+0i 1+0i 2+3i

[3]  2+0i 1+0i 1+0i 2+3i

Miscellaneous Operators

These Operators are used for specific purpose and not general mathematical or logical computation


  • “:” Creates series of sequence numbers for a vector
  • “%in%” Used to identify if an element belongs to a vector
  • “%*%” multiplies a matrix with its transpose



S= matrix(c(3,2,1,4,2,3) nrow=2, ncol=3, byrow = TRUE)

p=S%*% t(S)



    [,1]  [,2]

[1,]    14     19

[2,]    19     29

"0 Responses on Operators"

Leave a Message

Your email address will not be published.

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 28th October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
DW offer

Sign Up or Login to view the Free Operators.