[R] reading short int and float from binary connection
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Mar 17 12:11:06 CET 2004
Angel Lopez wrote:
> Hi,
> I have a binary file with mixture of short integers (2 bytes) and floats
> (4 bytes).
> To get the data into R I use readBin reading each value one at a time
> (n=1) but it is giving me headaches, two questions:
> -In the "what" option is there any difference between "integer" and "int"?
> -To read the short int I use what="int" and size=2 and to read the
> floats I use what="double" and size=4, the strange thing is that
> sometimes it works but other times it reads wrong values.
> Any clues where my mistake might be?
> Thanks
> Angel
Are the inetgers signed or not? You might want to set signed = FALSE for
unsigned integers.
Are you sure you are reading each time from the beginning of the connection?
Are you really sure about the file format specifications?
Difficult to track down without your code, the file format's
specification, and an example file..
Uwe Ligges
More information about the R-help
mailing list