How R performs element wise comparison?

r

#1

I am currently creating one logical vector but while creating it I have one question that comes to my mind is that how R performs this comparison.

` c(4,5,6) > 4`

The left side it has one vector and on the right side, it has a single value.I want to know how R performs the comparison of the vector to a single value.


#2

hello @harry,

If you see the results in the R console:

Each element of the vector is compared to 4 and a T/F is returned based on if the element satisfies the condition or not.


#3

@harry - I think harry you want to ask about how R in back performs this calculation .R creates the copy of the value on the right equal to the length of the vector on the left and performs given task.

Hope this helps!

Regards,
Hinduja