I found that seek(..., origin = 'current', ...) and readBin(..., what = 'integer', ...) or 'int' do not work correctly. Did anyone have the same experience?
Please see the message at the bottom of this posting, and supply the information requested, including your OS. (If the latter is Windows, did you notice the warnings in ?seek.) On Sat, 21 Oct 2006, Zepu Zhang wrote:> I found that > seek(..., origin = 'current', ...) > and > readBin(..., what = 'integer', ...) > or 'int' > do not work correctly. > > Did anyone have the same experience? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
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') ...
Seemingly Similar Threads
- getting corrupted data when using readBin() after seek() on a gzfile connection
- Importing binary data
- Questions about readBin function (Was: dec2bin?)
- readBin: read from defined offset TO defined offset?
- readBin on binary non-blocking connections (Windows & Unix differences/bugs)