Page 217 - Data Science class 11
P. 217
2. < The Less than operator checks if each element of the first vector is less than the corresponding element
of the second vector.
Example
Enter the following code snippet:
first <- c( 3,7.5,12)
second <- c(7, 7.5, 5)
print(first<second)
The following result is produced:
3. == This assignment (equal to) operator checks if each element of the first vector is equal to the
corresponding element of the second vector.
Example
Enter the following code snippet:
first <- c( 3,7.5,12)
second <- c(7, 7.5, 5)
print(first==second)
print(first=second)
The following result is produced:
In the second print statement, the programmer used only a single =, which is not a relational operator. The compiler
has sent the error message.
4. <= The less than and equal to operator checks if each element of the first vector is less than or equal to
the corresponding element of the second vector.
Example
Enter the following code snippet:
first <- c( 3,7.5,12)
second <- c(7, 7.5, 5)
print(first<=second)
Programming with R 215

