On 12-04-13 4:45 PM, Waichler, Scott R wrote:
Hi, I've read up on readBin() and chapter 6 in the R Data Import/Export manual,
but I still can't read a binary file. Here is how the creator of the file
described the code that would be needed in Fortran:
You need to see what's in the file. The hexView package can dump it in
various formats; see example(viewFormat) for a couple.
If you can't figure it out from the dump, post it here, and someone
should be able to help.
Duncan Murdoch
"Every record has a return in fortran. The length of each record is nx*ny*4.
To read you would use the following:
nlayx = nx*ny*4
do iz=1,nz,4
read(binary file) var(1:nlayx)
enddo
nrest=mod(nx*ny*nz,nlayx)
read(binary file) var(1:nrest)"
The first value in the file should be 0.05, and all of the data values are
real. Here is what I get (with similar answers using double):
v<-readBin("plotb.251", numeric(), size=4, n=1)
v
[1] 1.614296e-39
v<-readBin("plotb.251", numeric(), size=4, n=1, endian="swap")
v
[1] 1.359775e-38
Platform is Intel Linux. How can I read the file described above?
Thanks,
Scott Waichler, PhD
Hydrology Group, Energy& Environment Directorate
Pacific Northwest National Laboratory
scott.waich...@pnnl.gov
______________________________________________
R-help@r-project.org 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.
______________________________________________
R-help@r-project.org 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.