Skip to content
Prev 79976 / 398502 Next

Matrix operations please help

Try this:

# test data
mm <- cor(iris[,-5])
mm

# get upper triangle from matrix
mm[lower.tri(mm)]

# if you want it as a data frame with columns for row and column names
as.data.frame.table(mm)[lower.tri(mm),]


In either of the cases above you could substitute row(mm) > col(mm)
for lower.tri(mm) if you like.
On 10/31/05, Srinivas Iyyer <srini_iyyer_bio at yahoo.com> wrote: