Skip to content
Prev 7203 / 29559 Next

reading select values from a binary file

?seek

The "where" argument is an offset in bytes, so you need to offet 2
bytes for each of your integers:

writeBin(1:20,"test.bip",size=2,endian="big")
cc <- file("test.bip","rb")
readBin(cc,"integer",n=1,size=2,endian="big")
seek(cc, 26)
readBin(cc,"integer",n=1,size=2,endian="big")
## [1] 14
close(cc)

Use seek(cc) to find the current offset on the connection.

HTH
On Thu, Dec 17, 2009 at 5:12 AM, Jonathan Thayn <jthayn at ilstu.edu> wrote: