Gregory Gentlemen <gregory_gentlemen <at> yahoo.ca> writes:

> 
> Greetings,
> 
> I have a seemingly simple task which I have not been able to solve today. I
want to construct a symmetric
> matrix of arbtriray size w/o using loops. The following I thought would do it:
>
 
 [snip]

p <- 6
Rmat <- diag(p)
vals <- rnorm(p*(p-1)/2)
Rmat[lower.tri(Rmat)] <- vals
Rmat[upper.tri(Rmat)] <- t(Rmat)[upper.tri(Rmat)]

  appears to work.

______________________________________________
R-help@stat.math.ethz.ch 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