[R] built a lower triangular matrix from dataframe
nymphita
nymphita at gmail.com
Wed Feb 15 16:33:06 CET 2012
Hello!
I'm trying to build a lower triangular matrix (with zeros in the diagonal)
from a particular dataframe.
The matrix I have to construct has 203 rows and 203 columns and that makes
20503 values to be included within (that's why I can't do it manually).
To illustrate the dataframe I have, I'll give you an example of a dataframe
and matrix with dimensions 6x6 (to make it shorter!)
My dataframe looks more or less like this (but longeeeer):
(i= number of row, j=number of column, k=value to be included in the matrix)
http://r.789695.n4.nabble.com/file/n4390813/df.png
An the matrix I should look like this:
http://r.789695.n4.nabble.com/file/n4390813/matrix.png
Can anyone help me about how to do it?
I'm a new R user, and I've tried several combinations of diag(),
lower.tri(), matrix(), etc. without any luck... and I don't know if I'm
unaware of a command that can work this out.
--
View this message in context: http://r.789695.n4.nabble.com/built-a-lower-triangular-matrix-from-dataframe-tp4390813p4390813.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list