[R] How I can read the binary file with "different type"?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Aug 22 08:01:03 CEST 2008


On Fri, 22 Aug 2008, Bingxiang Miao wrote:

> Hi all,
>
> I  have a binary file  which have 8*100 bytes. The structure of the file is
> as follows: every eigth bytes represent 2 data:the first four bytes is the
> little-endian for integer, the next four bytes is the little-endian for
> floating32. The structure of the following bytes is as the same as the first
> eight bytes'.
>
> As the function readBin only read the binary file with one structure like
> this: readBin("my data file",what="integer",size=4,n=200) or readBin("my
> data file",what="numeric",size=4,n=200).But only one type of the data can be
> read properly.

That's plain wrong, and the examples on the help page disprove it. Please 
do read the help before posting. The concept is to use multiple readBin 
calls from an open connection (as in the examples on the help page).

> Can anyone suggest me how should I read this file?

We DO suggest you 'should' read the posting guide and the help pages.

>
> Thanks in advance.
>
> Miao
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list