[R] Coerce rectangular matrix to symmetrical square matrix
Nathan S. Watson-Haigh
nathan.watson-haigh at csiro.au
Wed Jun 17 07:28:17 CEST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have a rectangular matrix of size 920 by 85. I'd like to coerce it into a
square matrix such that all row/col names are present in the new matrix and the
additional values are zero.
As an example:
A B C D
A 1 2 3 4
E 5 6 7 8
F 9 10 11 12
Would be coerced to:
A B C D E F
A 1 2 3 4 5 9
B 2 0 0 0 6 10
C 3 0 0 0 7 11
D 4 0 0 0 8 12
E 5 6 7 8 0 0
F 9 10 11 12 0 0
Any thoughts on how to achieve this?
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
iEYEARECAAYFAko4fvEACgkQ9gTv6QYzVL5gywCgsOpHJpTUXW98oHJ7jsSlo47X
mToAoI08QcZHvOgSFteqmQ/acAwDkaiR
=Hyod
-----END PGP SIGNATURE-----
More information about the R-help
mailing list