I just started learning R and in my first assignment, I face a problem where I need to compare a bunch of variables and while doing that I am supposed to get false when comp
From the ?Comparison
help page:
If the two arguments are atomic vectors of different types, one is coerced to the type of the other, the (decreasing) order of precedence being character, complex, numeric, integer, logical and raw.
On the same help page, the authors warn for using ==
and !=
for tests in if
-expressions. They recommend using identical()
instead:
7 == "7"
# TRUE
identical(7, "7")
# FALSE