NA values in Rcpp conditional
I am having trouble with conditionals in Rcpp. The best way to explain my problem is through an example. z <- seq(from=1,to=10,by=0.1) z[c(5,10,15,20,40,50,80)] <- NA src <- ' Rcpp::NumericVector vecz(z); for (int i=0;i<vecz.size();i++) { if (vecz[i] == NA_REAL) { std::cout << "Here is a missing value" << std::endl; } } ' func <- cxxfunction(signature(z="numeric"),src,plugin="Rcpp") func(z) # NULL From my understanding, NA_REAL represents the NA values for the reals in Rcpp and NA_Integer represents the NA values for integers. I'm not sure why the above conditional never returns true given z .