Recently, I found an error in my R code which is caused by the auto coercion by R. I accidentally compare a vector of string with an integer and the code runs successfully with most of the right comparison, which makes it very hard to know the mistake at the first place. So I want to know is there anything I can do to disable this auto coercion and raise an error just like what python does.
This is how R compares two variable with different types:
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.
For example,
'95'>90
#[1] TRUE
'100'>90
#[1] FALSE