[Rd] Setting NA from C code

Prof Brian Ripley ripley@stats.ox.ac.uk
Mon, 5 Nov 2001 15:16:46 +0000 (GMT)


On Mon, 5 Nov 2001, Duncan Murdoch wrote:

> In the maps library, NA's are inserted between polygons so lines() can
> be used to draw all polygons at once.  The code to do it is like this:
>
>             *x++ = NA_REAL;
>             *y++ = NA_REAL;
>
> where x and y are declared as
>
> 	double *x, *y, *range;
>
> and are the arguments passed in through a .C call.
>
> However, the values show up in R as -6.62314033633867e-229 instead of
> NA, so the drawing gets messed up.
>
> Any suggestions as to what might be going wrong?

You are probably not importing R_NaReal, which is what NA_REAL is a macro
reference to.  That's the point of globalvars.h, which the standard
Makefile forces to be included.

This will not be needed from 1.4.0 on.

>
> This is happening in Windows, using gcc 2.95.2, R source 1.3.1,
> platform i386-pc-mingw32.
>
> Duncan Murdoch
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._