[R] binary coding of NA, Nan etc.
Laurent Gautier
laurent at cbs.dtu.dk
Fri Sep 28 16:34:27 CEST 2001
Hello,
Thanks to the Pr. Ripley for the precise explanations.
Not so long long ago, I have been generating numerical binary data file
using java, and noticed that Double.NaN in java was just something very
big (1.797693e+308) when read in R through readBin. Being too lazy/in a
hurry to look for the reason I just turned the values greater than or
equal to that into NA when read in R.
As that is a rather dirty way of doing things, and as I am ignorant in
numbers binary representation, I was thinking a paramater to readBin or
writeBin specifying the convention wanted for the could be nifty.
Does it makes (any) sense ?
Laurent
Prof Brian D Ripley wrote:
>
> On Fri, 28 Sep 2001, Johann Petrak wrote:
>
> > I wonder which binary codings to use for the different
> > "special" values used in R.
> > I want to create binary coded files of double, int, and
> > string values that should get read into R using readBin.
>
> It depends on the system. R uses different values for IEC 60559
> (aka IEEE 754) systems and others.
>
> > Now, what is the correct way to code NA, NaN, Inf, and -Inf
> > for these types? The documentation for read/writeBin
> > doesnt contain any info on that ...
>
> (Well, it is not really a read/writeBin issue: we don't explain any of the
> machine-specific details there.)
>
> > (for int and string, there probably is only NA).
> > How to do this portably?
> >
> > The program should be compiled seperately from R, so
> > I cannot use R macros/configure for that.
>
> That's partly what Rmathlib and Rmath.h are for.
>
> On a IEEE-754 system use the IEEE-754 values for doubles.
>
> For integers and logicals, the NA value is INT_MIN, 0xff000000 usually.
>
> There is no special NA value for char * strings. But generally the value
> "NA" is interpreted as special.
>
> Reading the R source is the best way to answer such Qs.
>
> --
> Brian D. Ripley, ripley at 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-help 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-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list