how to get odd numbers

hi there,

i have a code
y <- 1:100

y %% 2
[1] 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
[70] 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

i want vice versa, means where 1 it become zero, and where zero it becomes 1
actually i want to know is there any function in R so that we can find odd numbers.

thank you,
rao

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.

I am new in R,
i am learning data.frame
adding columns,
generate 1:100
add another column for odd, even etc..
thank you