[R] Possible bugs in 'seek' and 'readBin'

Zepu Zhang zpzhang at uchicago.edu
Sun Oct 22 18:47:06 CEST 2006


Sorry I can't provide reproducible code because it involves
data files. I saw no warning messages.

I'm using Mac 10.3, but the R is compiled by myself from
command line. I'm reading in data from a XDR formatted file.
The first 4 bytes is a 'long' integer, the remainder is double. 

--- problem with 'integer' and 'int' ---

I can read in the doubles with

readBin(fid, 'double', n, 4, endian = 'swap')

n >= 1. No problem. However,

readBin(fid, 'integer', 1, 4, endian = 'swap')
readBin(fid, 'int', 1, 4, endian = 'swap')

return
""

I think even if the type is wrong, the result shouldn't be an
empty string.


---- problem with 'seek' ---

I have addresses a1, a2, a3, ...
When I do

seek(fid, a1)
...
seek(fid, a2)
...
seek(fid, a3)
...

The results are correct. But they're not if I do

seek(fid, a1)
...
seek(fid, a2 - a1, origin = 'current')
...
seek(fid, a3 - a2, origin = 'current')
...



More information about the R-help mailing list