[R] Reading Binary Files

Steve_Friedman at nps.gov Steve_Friedman at nps.gov
Wed Feb 11 17:04:01 CET 2009


I'm encountering some difficulty correctly reading binary files. The binary
files store data as "short"  rather than "double" , "int", or any of the
other  modes of the vector being read.

The data represents a regular grid of size 419 rows by 264 columns, to make
it more interesting, the data are daily records, for a total of 37 years.
The file size is therefore 419(rows) * 264(columns) * 365(days) * 37(years)

The product  of these dimensions is 1493869080 records.

I'm using the following code to read these into R (windows 2.8.1 )

 con <- file(file.choose(), open="rb")
 Year66 <- readBin(con, integer, signed=TRUE, n = 40374840)


returns 2046396

I'm betting that I'm defining the "what" incorrectly, but after numerous
attempts with different choices I'm wondering if readBin can handle "short"

Any help is greatly appreciated.


Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

Steve_Friedman at nps.gov
Office (305) 224 - 4282
Fax     (305) 224 - 4147

More information about the R-help mailing list