[R] built a lower triangular matrix from dataframe
Rui Barradas
rui1174 at sapo.pt
Wed Feb 15 18:02:16 CET 2012
Hello,
>
> I'm trying to build a lower triangular matrix (with zeros in the diagonal)
> from a particular dataframe.
>
This example constructs a lower triangular matrix from a vector, not a
data.frame.
(In your example, you also use a vector, the last column of the DF.)
x <- runif(15)
y <- matrix(0, nrow=6, ncol=6)
y[lower.tri(y)] <- x
# See the result
y
Hope this helps,
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/built-a-lower-triangular-matrix-from-dataframe-tp4390813p4391162.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list