[R] Memory Efficiency of Symmetric Matrix

Steven McKinney smckinney at bccrc.ca
Wed Jan 7 03:18:34 CET 2009


See also the dist() function documentation.
If you use indexing as described in ?dist
it is straightforward to maintain and
use a vector of the distances.

Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-----Original Message-----
From: r-help-bounces at r-project.org on behalf of Søren Højsgaard
Sent: Tue 1/6/2009 4:36 PM
To: Nathan S. Watson-Haigh; r-help at r-project.org
Subject: Re: [R] Memory Efficiency of Symmetric Matrix
 
You can do
mat[lower.tri(mat, diag=F)]
Søren

 
________________________________

Fra: r-help-bounces at r-project.org på vegne af Nathan S. Watson-Haigh
Sendt: on 07-01-2009 01:28
Til: r-help at r-project.org
Emne: [R] Memory Efficiency of Symmetric Matrix



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm generating a symmetric correlation matrix using a data matrix as input:
mat <- cor(data.mat)

My question is:
Is there a more memory efficient way to store this data? For instance, since:
all(mat == t(mat))
every value is duplicated, and I should be able to almost half the memory usage for large matrices.

Any thoughts/comments?

Cheers,
Nathan


- --
- --------------------------------------------------------
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- --------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org <http://enigmail.mozdev.org/> 

iEYEARECAAYFAklj9yAACgkQ9gTv6QYzVL6MGQCg1CHsRGAwEMah/8ZuZ9QFI6O5
lcIAnjZ68DE9FABLMd07A3AfdMPRpXIH
=5bet
-----END PGP SIGNATURE-----

______________________________________________
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.

______________________________________________
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