Extracting row and column names with its value from matrix in R
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] ] )
• 1,335 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Hello xxxxxxxx!
Questions similar to yours can already be found at:
We have closed your question to allow us to keep similar content in the same thread.
If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.
Cheers!
No i need to know how i can get the 3rd column with its value