I have a dataframe/matrix of equal rows and columns. I want to extract only the upper or lower triangle.
x<-data.frame(matrix(1:25,nrow=5))
colnames(x)<-LETTERS[1:5]
rownames(x)<-LETTERS[1:5]
x[upper.tri(x,diag=F)]
From this result, it is not possible to say what combination of column and row the value came from. So, I would like to have the row and column attributes in the results. Something like this:
Col Row Val
B A 6
C A 11
C B 12
...
I need to do this for a large correlation matrix. Thanks.