On Feb 15, 2012, at 11:47 AM, nymphita wrote:
Hi Tsjerk!
Thanks for your quick reply!
It's a nice way to built a lower triangular matrix with zeros in the
diagonal, but what I can't work out is *how to include the values of
the
third column of the dataframe inside the matrix*.
I just realized that I forgot to explain something about the
dataframe (the
meaning of i, j ,k) in my post:
The data frame has three columns, the first one (i) corresponds to
the "row
subscript" of the matrix [i, ], the second one (j) corresponds to the
"column subscript" of the matrix [ ,j], and the third column in the
dataframe (k) is the value that has to be in the matrix (in position
[i,
j]).
http://r.789695.n4.nabble.com/file/n4391099/df.png
You might be able to create a matrix of zeros withthis untested code:
zmat <- matrix(0, ncol=1+max(j), nrow=1+max(i) )
# Then populate it with:
zmat[ cbind(i,j) ] <- k
(Tested solutions offered when reproducible code is posted. Png images
of data on Nabble do not count as reproducible code in my estimation.
I cannot understand why you wouldn't post that data in the body of the
message.)
--
david.
The result is that the dataframe gives you a position and a value in
a lower
triangular matrix:
http://r.789695.n4.nabble.com/file/n4391099/matrix.png
Still can't find a solution to built a lower triangular matrix with
the
specific values of that dataframe...
Any more ideas, please?
--
View this message in context:
http://r.789695.n4.nabble.com/built-a-lower-triangular-matrix-from-dataframe-tp4390813p4391099.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@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.