[R-SIG-Mac] ISNA(NA_REAL) == false?

David Faden dfaden at gmail.com
Wed Jan 17 13:05:03 CET 2007


Hi,

Is it expected that ISNA(NA_REAL) will evaluate to false? From Writing
R Extensions, I'd expected it instead to evaluate to true, but this
seems not to be the case. What value should one use to represent an NA
in native code if not NA_REAL? (I am trying to test some code by using
a small C++ application to call it. Ultimately the code will be called
from within R, but I'm hoping to get more information out of gdb this
way. To get this to work, though, I need to be able to get the
equivalent of expressions such as rep(c(NA, 1), 50), in my native
code.)

isnan, etc., seem to be available.

Below is some example code and its output on my computer, along with
some version info. Thanks much for any insights into what's going on.

David
----
dfaden at iastate.edu
AIM: pitulx
----

na.cpp:
#include <iostream>
#include <R_ext/Arith.h>

int main()
{
  if (!ISNA(NA_REAL)) {
    std::cout << "Hm.\n";
  }
}

Output:
$ g++ -I/Library/Frameworks/R.framework/Versions/Current/Resources/include
-L/Library/Frameworks/R.framework/Versions/Current/Resources/lib -lR
na.cpp
$ R CMD ./a.out
Hm.

----

g++ version:
i686-apple-darwin8-g++-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5250)

R version:
platform       i386-apple-darwin8.8.1
arch           i386
os             darwin8.8.1
system         i386, darwin8.8.1
status
major          2
minor          4.1
year           2006
month          12
day            18
svn rev        40228
language       R
version.string R version 2.4.1 (2006-12-18)

I'm running Mac OS X 10.4.8.



More information about the R-SIG-Mac mailing list