I've implemented a new approch of NA
handling in Rcpp11
(it is straightforward to port this to Rcpp
).
To test for missing values in Rcpp
there are several ways:
- rely on R api macros (NA_REAL, ...)
- use
Vector<RTYPE>::is_na(.)
- use traits::is_na(.)
These lack expressiveness and what I've implemented in Rcpp11
allows this syntax:
double x ; int y; String s ; // ... values coming from somewhere
// we can just us the equality operator to test for equality against NA:
double b1 = x == NA ;
double b2 = NA == x ;
double b1 = y == NA ;
double b2 = NA == y ;
double b1 = s == NA ;
double b2 = NA == s ;