Re: [R] writing matrices (no subject)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 20 Jul 2005 - 18:05:09 EST

Please use a current version of R: they are much better at this! write.table was rewritten in R 2.1.0 to use *much* less memory.

There _is_ a `R Data Import/Export Manual' that dicsusses this. write.table was designed to write `tables' (data frames) not matrices. write.matrix (package MASS) does a much better job of the latter, memory-wise, in particular allowing the use of blocks.

That _is_ on the help page for write.table in your version of R.

Assuming this is a numeric matrix, it is taking up 373MB of storage. It is not too surprising that you are having problems manipulating it on a 1GB machine: my 1GB machine ended up swapping just creating such a matrix.

On Wed, 20 Jul 2005, David Ruau wrote:

> Hi All,
>
> I want to print a square matrix of 7000 x 7000 into a text file. But I
> got a error after few hours of computation...
> --------
> > write.table(MyDistMxDF, file = "temp.csv", sep=",", quote=F)
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> Error: vector memory exhausted (limit reached?)
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> > q()
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> *** malloc: vm_allocate(size=8421376) failed (error code=3)
> *** malloc[2889]: error: Can't allocate region
> Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
> internal error in decompress1
> >
> ------
> I am running R 2.0.1 on MacOS X 10.3 with 1Gb ram.
> How could I write such a matrix to a text file.

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jul 20 18:09:54 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:51 EST