Miscellaneous Operators in R Programming Language

Rumman Ansari   Software Engineer   2023-03-24   8581 Share
☰ Table of Contents

Table of Content:


Miscellaneous Operators

These operators are used to for specific purpose and not general mathematical or logical computation.

Operator Description Example
: Colon operator. It creates the series of numbers in sequence for a vector.
a <- 2:8
print(a) 

it produces the following result −

[1] 2 3 4 5 6 7 8
%in% This operator is used to identify if an element belongs to a vector.
a1 <- 8
a2 <- 12
b <- 1:10
print(a1 %in% b) 
print(a2 %in% b) 

it produces the following result −

[1] TRUE
[1] FALSE
%*% This operator is used to multiply a matrix with its transpose.

R
= matrix( c(2,6,5,1,10,4),
nrow
= 2,ncol = 3,byrow = TRUE) b = R %*% t(R) print(b)

it produces the following result −

      [,1] [,2]
[1,]   65   82
[2,]   82  117