[R] reading binary file with different modes

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Mar 11 19:02:16 CET 2004

Angel Lopez wrote:

> I have a binary file representing a matrix with columns of different 
> variable type/mode (i.e. the file was saved from C using double and int 
> variables)
> I want to import it into R, I've been reading the R Import/Export and I 
> am able to use readBin for a file that contains only one variable type 
> (either all doubles or all ints) but I can not find the way to use it 
> when you have a file with mixture of the two.
> Could somebody point me to a solution or appropiatte reference?
> Thanks,
> Angel

You have to loop over something like:

  readBin(x, "double")
  readBin(x, "integer", size=2)

Uwe Ligges

More information about the R-help mailing list