I know this issue is resolved already (thank you again for help) but what can I do if variables are integers (not numbers)?
Even if I change the code into:
this has an easy fix, its a shame that the error message isnt more help in diagnosing the issue...
The problem you faced is a result of the if_else() function, which has particular constraints. It wants consistent data types in each of its 3 paramers (test expression, yes exp, no exp) . if we are dealing with integers as inputs (the .x) then its wrong to set the value to 1 which to R is a double value, rather our code should set the value to 1L which is an integer.