There is an is.odd() function in the schoolmath package. The calculation you made would do basically the same thing. To invert the output, I would just use.
1 - y %% 2
Could you explain more about what you are trying to achieve? I am wondering about the need to invert your current calculation.