[R] How I can read the binary file with "different type"?
Moshe Olshansky
m_olshansky at yahoo.com
Fri Aug 22 05:36:38 CEST 2008
Hi Miao,
I can write a function which takes an integer and produces a float number whose binary representation equals to that of the integer, but this would be an awkward solution.
So if nobody suggests anything better I will write such a function for you, but let's wait for a better solution.
--- On Fri, 22/8/08, Bingxiang Miao <miao2007 at gmail.com> wrote:
> From: Bingxiang Miao <miao2007 at gmail.com>
> Subject: [R] How I can read the binary file with "different type"?
> To: r-help at r-project.org
> Received: Friday, 22 August, 2008, 11:51 AM
> 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.
>
> Can anyone suggest me how should I read this file?
>
> 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.
More information about the R-help
mailing list