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
This will give you a matrix with the row/column names of the respective
values. Not sure what you meant by a list, but you can convert the matrix to
a list.
m2
a b c d e
A 1 5 9 13 17
B 2 6 10 14 18
C 3 7 11 15 19
D 4 8 12 16 20
cbind(row=rownames(m2)[row(m2)[lower.tri(m2)]],
+
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)
Dear Group,
I have a matrix (157 X 157 ) with correlation values.
I want to convert the unique elements into a long list
so that I can add an extra variable and plot them.
Example:
A B C D
alfa 1 0.3 0.8 -0.3
beta 0.2 1 -0.3 0.4
echo 0.9 -0.3 1 0.5
tang -0.5 0.5
See ?reshape
Uwe Ligges
Srinivas Iyyer wrote:
Dear Group,
I have a matrix (157 X 157 ) with correlation values.
I want to convert the unique elements into a long list
so that I can add an extra variable and plot them.
Example:
A B C D
alfa 1 0.3 0.8 -0.3