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!
An alternate:
cor_relation[abs(cor_relation) < 0.6] <- NA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With