Reputation: 311
I am currently working on a dataset using R. I have created a correlation martix(Pearson) for my variables.But now I want to put a threshold for the values shown in matrix. I am trying the following code:
cor_relation = cor(mydata_frame, use="all.obs", method="pearson")
I get the following output:
200605_s_at 202592_at 202958_at
200605_s_at 1.000000000 0.295065389 0.169772244
202592_at 0.695065389 1.000000000 -0.534394180
202958_at 0.869772244 -0.534394180 1.000000000
I want to find the following output(when i put the threshold 0.6):
200605_s_at 202592_at 202958_at
200605_s_at 1.000000000 NA NA
202592_at 0.695065389 1.000000000 NA
202958_at 0.869772244 NA 1.000000000
Thanks in advance for help!
Upvotes: 4
Views: 6676
Reputation: 81693
is.na(cor_relation) <- abs(cor_relation) < 0.6
will replace all coefficients with an absolute value of less than 0.6 with NA
.
Upvotes: 5