?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
cl
I tried using the seek() function, but it did not work as I thought it would.
Perhaps I have done something wrong:
> writeBin(1:20,"desktop/test.bip",size=2,endian="big")
> cc <- file("desktop/test.bip","rb")
> readBin(cc,"integer",n=1,size=2,endian="big")
[1] 1
> seek(cc,13)
[1] 2
> readBin(cc,
On Wed, 9 Dec 2009 10:58:01 -0600 Jonathan Thayn
wrote:
> Now I want to open select values from the binary file, not a complete
> line. Say I want to read values 3, 7, and 10, process them, write the
> result, and then read values 4, 5, and 17. How do I direct readBin to
> those specific valu
If you can read the whole file at once it might be better to push the
results into a matrix for indexing in R. This could also be useful for
reading chunks of the file, and processing in parts. seek is fine but
if you are moving around for three values each read it will be slow.
If the arrangement
On Wed, Dec 9, 2009 at 6:20 PM, rick reeves wrote:
> Hello All:
> Faced with a similar challenge, and NOT wanting to resort to writing a C
> language function
> employing fseek(), I just used two readBin calls: One to read (and
> implicitly discard) data up
> to the spot I actually wanted to read,
Hello All:
Faced with a similar challenge, and NOT wanting to resort to writing a C
language function
employing fseek(), I just used two readBin calls: One to read (and
implicitly discard) data up
to the spot I actually wanted to read, and a second call to read the
desired information.
here is
On Wed, Dec 9, 2009 at 4:58 PM, Jonathan Thayn wrote:
> Hopefully there is a simple solution to this problem. I process really large
> satellite images in R and, in order to not offend the memory-limitation
> demi-gods, I open each row of the imagery one at a time, process it, write
> the resul
Hopefully there is a simple solution to this problem. I process really large
satellite images in R and, in order to not offend the memory-limitation
demi-gods, I open each row of the imagery one at a time, process it, write the
results, and then open the next line. I use readBin() to open each l