Operator in R Programming Language

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

Table of Content:


R has several operators to perform tasks including arithmetic, logical and bitwise operations. In this article, you will learn about different R operators with the help of examples.

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. R language is rich in built-in operators and provides following types of operators.

Types of Operators

R has many operators to carry out different mathematical and logical operations.

Operators in R can mainly be classified into the following categories.

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

R Arithmetic Operators

These operators are used to carry out mathematical operations like addition and multiplication. Here is a list of arithmetic operators available in R.

Arithmetic Operators in R
Operator Description
+ Addition
Subtraction
* Multiplication
/ Division
^ Exponent
%% Modulus (Remainder from division)
%/% Integer Division

R Relational Operators

Relational operators are used to compare between values. Here is a list of relational operators available in R.

Relational Operators in R
Operator Description
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to

R Logical Operators

Logical operators are used to carry out Boolean operations like ANDOR etc.

Logical Operators in R
Operator Description
! Logical NOT
& Element-wise logical AND
&& Logical AND
| Element-wise logical OR
|| Logical OR

R Assignment Operators

These operators are used to assign values to variables.

Assignment Operators in R
Operator Description
<-, <<-, = Leftwards assignment
->, ->> Rightwards assignment