[R] reading raw matrix saved with writeBin

Ranjan Maitra maitra at iastate.edu
Thu Mar 15 03:09:54 CET 2007


On Wed, 14 Mar 2007 18:45:53 -0700 (PDT) Milton Cezar Ribeiro <milton_ruser at yahoo.com.br> wrote:

> Dear Friends,
> 
> I saved a matrix - which contans values 0 and 1 - using following command:
> writeBin (as.integer(mymatrix), "myfile.raw",  size=1).
> 
> It is working fine and I can see the matrix using photoshop. But now I need
> read the matrices again (in fact I have a thousand of them) as matrix into R but when
> I try something like  mat.dat<-readBin ("myfile.raw",size=1) I can´t access the
> matrix
> 
> Kind regards,
> 
> Miltinho
> 
> __________________________________________________
> 
> 
> 	[[alternative HTML version deleted]]
> 

Look up the help file. There is an explicit example. Basically, you need to tell the file to read in binary.

In fact, I am a little surprised your first command works while writing.

HTH!
Ranjan



More information about the R-help mailing list