[R] Matrix operations please help

Gabor Grothendieck ggrothendieck at gmail.com
Mon Oct 31 19:55:33 CET 2005


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:
> Dear Group,
> I am a novice R programmer with little statistical
> background. I am a molecular biologist by training.
>  I generated a correlation matrix (157 X 157) for 157
> variables.
>
> I want to selection only the unique values (values
> that are either side of the diagnol).  I want these
> unique correltaion values in a list.
>
> How can I do this. could any one help me please.
>
> thank you.
>
> sr
>
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list