(m <- rbind(2:3, 0:-1))
(M <- as(m, "dgeMatrix"))(T <- as(M, "dtrMatrix")) ## upper triangular is default
## hence this may surprise at first:
(T2 <- as(t(M), "dtrMatrix"))# is factually diagonal
## and different from
(T3 <- t(T)) # which is *lower* triangular:
str(T3)
Run the code above in your browser using DataLab