Hi,
the is.double command test for the double-precision and not if the variable is even or not.
and if you sum directly the %%2values, you will only sum the binary result, which correspond to the number of even and not null values.
So, as a solution, firstly, you can apply the sum on the original vector without converting numbers to NA, for example: