Operator
Operator
Himanshi Swami
Overview
Topic: Introduction to R
Types of Types of Operators in R
Operators in Arithmetic Operators
Relational Operators
R Logical Operators
Assignment Operators
Miscellaneous Operators
Addition Operator(+):
The value at the corresponding positions of both the operands are added.
Subtraction Operator(-):
Input : a<- 6
b<- 8.4
print(a-b)
Output : -2.4
9/3/20XX Presentation Title 8
Multiplication Operator(*)
The multiplication of corresponding elements of vectors and Integers are multiplied with
the use of ‘*’ operator.
Division Operator(/)
The first operand is divided by the second operand with the use of ‘/’ operator
Input : a<-1
b<-0
Output ; -Inf
1. > This operator will return TRUE when every element in the first vector is
greater than the corresponding element of the second vector.
2. < This operator will return TRUE when every element in the first vector is less
then the corresponding element of the second vector.
3. <= This operator will return TRUE when every element I n the first vector is
less than or equal to the corresponding element of another vector.
4. >= This operator will return TRUE when every element in the first vector is
greater than or equal to the corresponding element of another vector.
5. == The operator will return TRUE when every element in the first vector is
equal to the corresponding element of the second vector.
6. != This operator will return TRUE when every element in the first vector is not
equal to the Corresponding element of the second vector.
9/3/20XX Presentation Title 14
9/3/20XX Presentation Title 15
LOGICAL
OPERATORS
LOGICAL OPERATORS
• Logical operations simulate element-wise decision operations, based
on the specified operator between the operands, which are then
evaluated to either TRUE or FALSE Boolean value.
• Any non zero integer value is considered as TRUE value, be it
complex or real number.
• The logical operators in R programming are used to combine two or
more conditions, and perform the logical operations using &(Logical
AND), |(Logical OR) and !(Logical NOT).
Checks for the vale 0.1 in the specified list. It exists, therefore, prints TRUE.
Colon Operator(:) :
Prints a list of elements starting with the element before the color to the element after it.
Input : print(1:5)
Output : 1 2 3 4 5