Skip to content

almost lower triangular matrices

1 message · Rolf Turner

#
> m <- matrix(0,4,4)
 > m[row(m)<col(m)] <- x
 > m <- t(m)
 > m
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    1    0    0    0
[3,]    2    3    0    0
[4,]    4    5    6    0


The fiddle with the transposing is needed because R puts
data into matrices column-by-column, not row-by-row.

				cheers,

					Rolf Turner
					rolf at math.unb.ca
Michael Anyadike-Danes wrote: