RE: [R] Binary Matrices

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Thu 14 Apr 2005 - 00:33:07 EST

> -----Original Message-----
> From: Uwe Ligges
>
> Mark Edmondson-Jones wrote:
>
> > I'm wanting to perform analysis (e.g. using eigen()) of
> binary matrices - i.e. matrices comprising 0s and 1s.
> >
> > For example:
> >
> > n<-1000
> > test.mat<-matrix(round(runif(n^2)),n,n)
> > eigen(test.mat,only.values=T)
> >
> > Is there a more efficient way of setting up test.mat, as
> each cell only requires a binary digit? I imagine R is
> setting up a structure which could contain n^2 floats.
>
> No. In principle you could use logicals,

... but that doesn't save any memory:

> object.size(integer(1e6))

[1] 4000028
> object.size(logical(1e6))

[1] 4000028

> but that does not help for further calculations in eigen().

Besides, if the problem size is really 1000 x 1000, one matrix in double precision is only 8MB. As Reid said, if the matrix is sparse, there's probably a lot more saving in both memory and computation by using SparseM and Matrix packages.

Cheers,
Andy  

> Uwe Ligges
>
>
> > Thanks in advance for any help.
> >
> > Regards,
> > Mark
> >
> >
> > This message has been checked for viruses but the contents
> of an attachment
> > may still contain software viruses, which could damage your
> computer system:
> > you are advised to perform your own checks. Email
> communications with the
> > University of Nottingham may be monitored as permitted by
> UK legislation.
> >
> > ______________________________________________
> > 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
>
>
> ______________________________________________
> 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
>
>
>



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 Thu Apr 14 00:47:41 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:07 EST