I\'m converting R based code into Rcpp based code. The head of my function is:
NumericMatrix createMatrixOfLinkRatiosC(NumericMatrix matr, double threshold4C
R has both NaN and NA (which is really a special kind of NaN) for representing missing values. This is important to know because there are many functions that check if a value is NaN-y (NA or NaN):
Some truth tables for functions from the R/C API (note the frustrating lack of consistency)
+---------------------+
| Function | NaN | NA |
+---------------------+
| ISNAN | t | t |
| R_IsNaN | t | f |
| ISNA | f | t |
| R_IsNA | f | t |
+---------------------+
and Rcpp:
+-------------------------+
| Function | NaN | NA |
+-------------------------+
| Rcpp::is_na | t | t |
| Rcpp::is_nan | t | f |
+-------------------------+
and from the R interpreter (note: Rcpp tries to match this, rather than the R/C API):
+---------------------+
| Function | NaN | NA |
+---------------------+
| is.na | t | t |
| is.nan | t | f |
+---------------------+
Unfortunately it's a confusing landscape, but this should empower you a bit.