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:
vec = c(-5,4,3,NA,-9,2, NA,1, 20)
sum(vec[vec>0 & !vec%%2], na.rm = T)
in your case, you can do:
sum(vec[!vec%%2], na.rm = T)
good luck.