Hi all,

If I have a vector A<-1:6, I would like to convert A to an upper
matrix M=[0 1 2 3 ; 0 0 4 5 ; 0 0 0 6; 0 0 0 0].
That is, if the length of the known vector is n, then the order m of
the matrix I'd like to have should satisfy m(m-1)/2=n
How could I do this in R?
I really don't want to do it using a loop. Is there a function in R to do this ?

Thanks!

Best,
Zhishi

______________________________________________
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