Hello,

You should address your questions to R-Help, the odds of getting more and better answers are greater.

As for your question, the trick is to use function ?lower.tri. (There's also an upper.tri) Something like the following.


x <- 1:6

m <- matrix(0, nrow = 4, ncol = 4)
m[lower.tri(m)] <- x
res <- m + t(m)
res

Hope this helps,

Rui Barradas

Em 12-01-2014 21:21, yolande....@gmail.com escreveu:
Hi Rui,

You might not remember me but you have been very helpful in the past wit 
questions related to R. I saw one of your reply about creating a lower 
triangular matrix from a vector.
I have a column in a data frame that I want to convert to a symmetric matrix 
with all 0 on the diagonal.
Could you help?

I appreciate.
Thanks,
Yolande

_____________________________________
Sent from http://r.789695.n4.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.

Reply via email to