The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)

here is an example of file:
1 1 1.0 1.0 "HEAD" 160 224 3
23.4  34.5 ......


I tried to read the first line with readBin (results are copied below):

> zz <- file("heads.hds", "rb")
> readBin(zz,what="integer",n=2)
[1] 1 1
> readBin(zz,what="double",n=2)
[1]  7.812502e-03 6.013470e-154
> readBin(zz,what="character",n=1)
[1] "    HEAD "
> readBin(zz,what="integer",n=3)
[1] 14680064    65536        0
>


Thanks





On Thu, Dec 17, 2009 at 3:52 PM, Phil Spector <spec...@stat.berkeley.edu>wrote:

> Kapo -
>   You'll get a better response if you tell us what you've already tried,
> and an even better response if you
> can provide a reproducible example.
>
>                                        - Phil Spector
>                                         Statistical Computing Facility
>                                         Department of Statistics
>                                         UC Berkeley
>                                         spec...@stat.berkeley.edu
>
>
>
> On Thu, 17 Dec 2009, kapo coulibaly wrote:
>
>  Is it possible to read fortran binaries with R? I tried unsucessfully and
>> my
>> understanding is that fortran write binaries with leading and trailing
>> bytes. I get numbers but not the right ones.
>> Thanks
>>
>> ps: the binary I'm interested in reading is a MODFLOW output with a mix of
>> character, double and integers.
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to