Off topic:Extracting row and column names with its value from matrix in R
0
0
Entering edit mode
5.0 years ago
xxxxxxxx ▴ 20

my matrix is like this-

          MU101188  MU101310    MU101326    MU10251
MU101188    1        0.506       -0.006     -0.006
MU101310   -0.006       1        -0.006     -0.006
MU101326  -0.006    -0.006            1     -0.006
MU10251   -0.006    -0.006        0.806         1

I need to extract all pairs with their value for which the value is greater than or equal to 0.5. I m using the following R script which gives me the row and column name, but I also want a 3rd column consist of its value

Pmatrix = read.csv ("file.csv", header= TRUE, row.names = 1)
sig_values <- which(Pmatrix>=0.5, arr.in=TRUE)
cbind.data.frame(colIDs = colnames(Pmatrix)[ sig_values[, 1] ],rowIDs = rownames(Pmatrix)[ sig_values[, 2] ] )
R r • 1.2k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 1943 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6